SimGrid: Queue

SimGrid 3.10 Versatile Simulation of Distributed Systems

- Home page
- Online documentation
- Dev's Corner

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Typedefs | Functions
Queue
Misc general purposes library components

Synchronized message exchanging queue. More...

## Typedefs
typedef struct s_xbt_queue_ * | xbt_queue_t
| Queue data type (opaque type)

## Functions
xbt_queue_t | xbt_queue_new (int capacity, unsigned long elm_size)
| Create a new message exchange queue.
void | xbt_queue_free (xbt_queue_t *queue)
| Destroy a message exchange queue.
unsigned long | xbt_queue_length (const xbt_queue_t queue)
| Get the queue size.
void | xbt_queue_push (xbt_queue_t queue, const void *src)
| Push something to the message exchange queue.
void | xbt_queue_pop (xbt_queue_t queue, void *const dst)
| Pop something from the message exchange queue.
void | xbt_queue_unshift (xbt_queue_t queue, const void *src)
| Unshift something to the message exchange queue.
void | xbt_queue_shift (xbt_queue_t queue, void *const dst)
| Shift something from the message exchange queue.
void | xbt_queue_push_timed (xbt_queue_t queue, const void *src, double delay)
| Push something to the message exchange queue, with a timeout.
void | xbt_queue_unshift_timed (xbt_queue_t queue, const void *src, double delay)
| Unshift something to the message exchange queue, with a timeout.
void | xbt_queue_shift_timed (xbt_queue_t queue, void *const dst, double delay)
| Shift something from the message exchange queue, with a timeout.
void | xbt_queue_pop_timed (xbt_queue_t queue, void *const dst, double delay)
| Pop something from the message exchange queue, with a timeout.

## Detailed Description

Synchronized message exchanging queue.

These is the classical producer/consumer synchronization scheme, which all concurrent programmer recode one day or another.

The good thing of this implementation is that it works seamlessly in your universe. When using one of the classical simulation interface (such as MSG), it achieves the synchronization on top of the simulator. If you use instead the real life implementation comming with GRAS, it uses the synchronization of your OS (whatever could it be). The choice is done at link time.

For performance concerns, the content of queue must be homogeneous, just like dynars (see the Dynar: generic dynamic array section). Actually, queues use a dynar to store the data, and add the synchronization on top of it.

## Function Documentation

xbt_queue_t xbt_queue_new | ( | int | capacity,
|  | unsigned long | elm_size
| ) |  |

Create a new message exchange queue.

Parameters

  capacity | the capacity of the queue. If non-nul, any attempt to push an item which would let the size of the queue over this number will be blocking until someone else pop some data
  elm_size | size of each element stored in it (see xbt_dynar_new)

void xbt_queue_free | ( | xbt_queue_t * | queue | ) |

Destroy a message exchange queue.

Any remaining content is leaked.

void xbt_queue_push | ( | xbt_queue_t | queue,
|  | const void * | src
| ) |  |

Push something to the message exchange queue.

This is blocking if the declared capacity is non-nul, and if this amount is reached.

See Also
  xbt_dynar_push

void xbt_queue_pop | ( | xbt_queue_t | queue,
|  | void *const | dst
| ) |  |

Pop something from the message exchange queue.

This is blocking if the queue is empty.

See Also
  xbt_dynar_pop

void xbt_queue_unshift | ( | xbt_queue_t | queue,
|  | const void * | src
| ) |  |

Unshift something to the message exchange queue.

This is blocking if the declared capacity is non-nul, and if this amount is reached.

See Also
  xbt_dynar_unshift

void xbt_queue_shift | ( | xbt_queue_t | queue,
|  | void *const | dst
| ) |  |

Shift something from the message exchange queue.

This is blocking if the queue is empty.

See Also
  xbt_dynar_shift

void xbt_queue_push_timed | ( | xbt_queue_t | queue,
|  | const void * | src,
|  | double | delay
| ) |  |

Push something to the message exchange queue, with a timeout.

See Also
  xbt_queue_push

void xbt_queue_unshift_timed | ( | xbt_queue_t | queue,
|  | const void * | src,
|  | double | delay
| ) |  |

Unshift something to the message exchange queue, with a timeout.

See Also
  xbt_queue_unshift

void xbt_queue_shift_timed | ( | xbt_queue_t | queue,
|  | void *const | dst,
|  | double | delay
| ) |  |

Shift something from the message exchange queue, with a timeout.

See Also
  xbt_queue_shift

void xbt_queue_pop_timed | ( | xbt_queue_t | queue,
|  | void *const | dst,
|  | double | delay
| ) |  |

Pop something from the message exchange queue, with a timeout.

See Also
  xbt_queue_pop