Changeset 7093a32 in mainline for uspace/lib/c/include/adt/dynamic_fifo.h
- Timestamp:
- 2010-09-26T15:20:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4edd39fc
- Parents:
- 2544442
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/dynamic_fifo.h
r2544442 r7093a32 32 32 33 33 /** @file 34 * 35 * 34 * Dynamic first in first out positive integer queue. 35 * Possitive integer values only. 36 36 */ 37 37 … … 40 40 41 41 /** Type definition of the dynamic fifo queue. 42 * 42 * @see dyn_fifo 43 43 */ 44 44 typedef struct dyn_fifo dyn_fifo_t; … … 47 47 * @see dyn_fifo 48 48 */ 49 typedef dyn_fifo_t * 49 typedef dyn_fifo_t *dyn_fifo_ref; 50 50 51 51 /** Dynamic first in first out positive integer queue. 52 * 53 * 52 * Possitive integer values only. 53 * The queue automatically resizes if needed. 54 54 */ 55 struct dyn_fifo{ 56 /** Stored item field. 57 */ 58 int * items; 59 /** Actual field size. 60 */ 55 struct dyn_fifo { 56 /** Stored item field. */ 57 int *items; 58 /** Actual field size. */ 61 59 int size; 62 /** First item in the queue index. 63 */ 60 /** First item in the queue index. */ 64 61 int head; 65 /** Last item in the queue index. 66 */ 62 /** Last item in the queue index. */ 67 63 int tail; 68 /** Consistency check magic value. 69 */ 64 /** Consistency check magic value. */ 70 65 int magic_value; 71 66 }; 72 67 73 /** Initializes the dynamic queue. 74 * @param[in,out] fifo The dynamic queue. 75 * @param[in] size The initial queue size. 76 * @returns EOK on success. 77 * @returns EINVAL if the queue is not valid. 78 * @returns EBADMEM if the fifo parameter is NULL. 79 * @returns ENOMEM if there is not enough memory left. 80 */ 81 extern int dyn_fifo_initialize(dyn_fifo_ref fifo, int size); 82 83 /** Appends a new item to the queue end. 84 * @param[in,out] fifo The dynamic queue. 85 * @param[in] value The new item value. Should be positive. 86 * @param[in] max_size The maximum queue size. The queue is not resized beyound this limit. May be zero or negative (<=0) to indicate no limit. 87 * @returns EOK on success. 88 * @returns EINVAL if the queue is not valid. 89 * @returns ENOMEM if there is not enough memory left. 90 */ 91 extern int dyn_fifo_push(dyn_fifo_ref fifo, int value, int max_size); 92 93 /** Returns and excludes the first item in the queue. 94 * @param[in,out] fifo The dynamic queue. 95 * @returns Value of the first item in the queue. 96 * @returns EINVAL if the queue is not valid. 97 * @returns ENOENT if the queue is empty. 98 */ 99 extern int dyn_fifo_pop(dyn_fifo_ref fifo); 100 101 /** Returns and keeps the first item in the queue. 102 * @param[in,out] fifo The dynamic queue. 103 * @returns Value of the first item in the queue. 104 * @returns EINVAL if the queue is not valid. 105 * @returns ENOENT if the queue is empty. 106 */ 107 extern int dyn_fifo_value(dyn_fifo_ref fifo); 108 109 /** Clears and destroys the queue. 110 * @param[in,out] fifo The dynamic queue. 111 * @returns EOK on success. 112 * @returns EINVAL if the queue is not valid. 113 */ 114 extern int dyn_fifo_destroy(dyn_fifo_ref fifo); 68 extern int dyn_fifo_initialize(dyn_fifo_ref, int); 69 extern int dyn_fifo_destroy(dyn_fifo_ref); 70 extern int dyn_fifo_push(dyn_fifo_ref, int, int); 71 extern int dyn_fifo_pop(dyn_fifo_ref); 72 extern int dyn_fifo_value(dyn_fifo_ref); 115 73 116 74 #endif
Note:
See TracChangeset
for help on using the changeset viewer.