push your data on a cp_priority_list then retrieve them by priority. More...
#include "common.h"
#include "config.h"
#include "collection.h"
#include "linked_list.h"
Go to the source code of this file.
Data Structures | |
struct | _cp_priority_list |
Defines | |
#define | PRIORITY_LIST_IMMEDIATE 1 |
#define | PRIORITY_LIST_NORMAL 2 |
#define | cp_priority_list_create(immediate, normal_priorities, weights) |
Internal destructor. | |
#define | cp_priority_list_get_next(l) cp_priority_list_get_next_by_option((l), (l)->mode) |
Get the "first" entry of the list with default-mode. | |
#define | cp_priority_list_rdlock(list) cp_priority_list_lock(list, COLLECTION_LOCK_READ) |
Lock the collection for reading. | |
#define | cp_priority_list_wrlock(list) cp_priority_list_lock(list, COLLECTION_LOCK_WRITE) |
Lock the collection for writing. | |
Typedefs | |
typedef CPROPS_DLL struct _cp_priority_list | cp_priority_list |
Functions | |
cp_priority_list * | cp_priority_list_create_by_option (int immediate, int normal_priority_queues, int *weights, cp_compare_fn compare_fn, cp_copy_fn copy_fn, cp_destructor_fn item_destructor, int mode) |
Constructor with all parameters. | |
void | cp_priority_list_destroy (cp_priority_list *list) |
Destructor. | |
void | cp_priority_list_destroy_by_option (cp_priority_list *list, int option) |
Destructor with locking option. | |
void * | cp_priority_list_insert (cp_priority_list *list, void *item, int priority) |
Inserts an entry to the list with priority and default-mode. | |
void * | cp_priority_list_insert_by_option (cp_priority_list *list, void *item, int priority, int mode) |
Inserts an entry to the list with priority and mode. | |
void * | cp_priority_list_get_next_by_option (cp_priority_list *list, int mode) |
Get the "first" entry of the list with mode. | |
int | cp_priority_list_is_empty (cp_priority_list *list) |
Test if object is empty. | |
int | cp_priority_list_lock (cp_priority_list *list, int lock_mode) |
Lock the collection with mode. | |
int | cp_priority_list_unlock (cp_priority_list *list) |
Unlock the collection. | |
long | cp_priority_list_item_count (cp_priority_list *list) |
Number of entries in the whole collection. |
push your data on a cp_priority_list then retrieve them by priority.
priority levels are 0 - immediate: a priority list instantiated with an immediate priority will only return immediate priority items as long as such items are present on the immediate priority sub queue. 1 - the first 'normal priority' subqueue defined. Subqueues are defined with a weight. If you define the first subqueue with say weight 2 and the second with 1, in the absence of an immediate priority subqueue, calling cp_priority_list_get_next will return 2 items from the queue with weight 2, then 1 item from the queue with weight 1. Do not confuse the subqueue index, which is used to determine which queue you push items on (ie, what 'priority' they receive) with the actual weights. You could easily construct a cp_priority_list where priority 1 items have a lower weight than priority 2 items and vice versa.