Cp_priority_list


Files

file  priority_list.h

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)
#define cp_priority_list_get_next(l)   cp_priority_list_get_next_by_option((l), (l)->mode)
#define cp_priority_list_rdlock(list)   cp_priority_list_lock(list, COLLECTION_LOCK_READ)
#define cp_priority_list_wrlock(list)   cp_priority_list_lock(list, COLLECTION_LOCK_WRITE)

Typedefs

typedef CPROPS_DLL struct
_cp_priority_list 
cp_priority_list

Functions

int cp_priority_list_txlock (cp_priority_list *list, int type)
int cp_priority_list_txunlock (cp_priority_list *list)
void cp_priority_list_destroy (cp_priority_list *list)
void cp_priority_list_destroy_by_option (cp_priority_list *list, int mode)
cp_priority_list * cp_priority_list_create_by_option (int immediate, int normal_priority_queues, int *weight, cp_compare_fn compare_fn, cp_copy_fn copy_fn, cp_destructor_fn item_destructor, int mode)
void * cp_priority_list_insert (cp_priority_list *list, void *item, int priority)
void * cp_priority_list_insert_by_option (cp_priority_list *list, void *item, int priority, int mode)
int cp_priority_list_is_empty (cp_priority_list *list)
void * cp_priority_list_get_next_by_option (cp_priority_list *list, int mode)
int cp_priority_list_lock_internal (cp_priority_list *list, int lock_mode)
int cp_priority_list_unlock_internal (cp_priority_list *list)
int cp_priority_list_lock (cp_priority_list *list, int type)
int cp_priority_list_unlock (cp_priority_list *list)
int cp_priority_list_get_mode (cp_priority_list *list)
int cp_priority_list_set_mode (cp_priority_list *list, int mode)
int cp_priority_list_unset_mode (cp_priority_list *list, int mode)
long cp_priority_list_item_count (cp_priority_list *list)

Define Documentation

#define cp_priority_list_create ( immediate,
normal_priorities,
weights   ) 

Value:

cp_priority_list_create_by_option(immediate, normal_priorities, weights, \
                        NULL, NULL, NULL, COLLECTION_MODE_MULTIPLE_VALUES)
Simplified constructor.

Parameters:
immediate if true, create an immediate queue
normal_priority_queues 
weights table of weight factors

Definition at line 73 of file priority_list.h.

#define cp_priority_list_get_next (  )     cp_priority_list_get_next_by_option((l), (l)->mode)

Get the "first" entry of the list with default-mode.

The internal algorithm selects one of the non-empty list and returns the first entry of that list.

Definition at line 146 of file priority_list.h.

#define cp_priority_list_rdlock ( list   )     cp_priority_list_lock(list, COLLECTION_LOCK_READ)

Lock the collection for reading.

Definition at line 170 of file priority_list.h.

#define cp_priority_list_wrlock ( list   )     cp_priority_list_lock(list, COLLECTION_LOCK_WRITE)

Lock the collection for writing.

Definition at line 175 of file priority_list.h.


Function Documentation

CPROPS_DLL 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.

Parameters:
immediate if true, create an immediate queue
normal_priorities number of subqueues
weights table of weight factors
compare_fn compare method
copy_fn copy method
mode operation and locking mode

Definition at line 64 of file priority_list.c.

References COLLECTION_MODE_NOSYNC, cp_list_create_list(), and _cp_priority_list::immediate.

CPROPS_DLL void cp_priority_list_destroy ( cp_priority_list *  list  ) 

Destructor

Definition at line 36 of file priority_list.c.

References cp_priority_list_destroy_by_option().

CPROPS_DLL void cp_priority_list_destroy_by_option ( cp_priority_list *  list,
int  option 
)

Destructor with locking option.

Definition at line 41 of file priority_list.c.

References cp_list_destroy_by_option().

Referenced by cp_priority_list_destroy().

CPROPS_DLL void * cp_priority_list_get_next_by_option ( cp_priority_list *  list,
int  mode 
)

Get the "first" entry of the list with mode.

The internal algorithm selects one of the non-empty list and returns the first entry of that list.

Definition at line 232 of file priority_list.c.

References COLLECTION_LOCK_WRITE, cp_list_remove_tail(), cp_priority_list_txlock(), and cp_priority_list_txunlock().

CPROPS_DLL void * cp_priority_list_insert ( cp_priority_list *  list,
void *  item,
int  priority 
)

Inserts an entry to the list with priority and default-mode.

The entry is added to the list which holds the entries with given priority.

Parameters:
list the object
item the entry object
priority priority of the entry
Note:
If the priority is out of supported range, the items are added to the queue with lowest priority .

Definition at line 156 of file priority_list.c.

References cp_priority_list_insert_by_option().

CPROPS_DLL 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.

The entry is added to the list which holds the entries with given priority.

Parameters:
list the object
item the entry object
priority priority of the entry
mode locking mode
Note:
If the priority is out of supported range, the items are added to the queue with lowest priority .

Definition at line 161 of file priority_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_MULTIPLE_VALUES, COLLECTION_MODE_NOSYNC, CP_INVALID_FUNCTION_POINTER, CP_ITEM_EXISTS, cp_list_search(), and cp_priority_list_txlock().

Referenced by cp_priority_list_insert().

CPROPS_DLL int cp_priority_list_is_empty ( cp_priority_list *  list  ) 

Test if object is empty.

Return values:
true if no element contained.
false if at least one element is contained.

Definition at line 218 of file priority_list.c.

References COLLECTION_LOCK_READ, cp_priority_list_txlock(), and cp_priority_list_txunlock().

CPROPS_DLL long cp_priority_list_item_count ( cp_priority_list *  list  ) 

Number of entries in the whole collection.

Returns:
number of entries.

Definition at line 412 of file priority_list.c.

CPROPS_DLL int cp_priority_list_lock ( cp_priority_list *  list,
int  lock_mode 
)

Lock the collection with mode.

Parameters:
list the object
lock_mode locking mode

Definition at line 327 of file priority_list.c.

References COLLECTION_MODE_IN_TRANSACTION, and cp_priority_list_lock_internal().

CPROPS_DLL int cp_priority_list_unlock ( cp_priority_list *  list  ) 

Unlock the collection.

Definition at line 339 of file priority_list.c.

References COLLECTION_LOCK_WRITE, COLLECTION_MODE_IN_TRANSACTION, and cp_priority_list_unlock_internal().


Generated on Mon Dec 5 23:00:23 2011 for cprops by  doxygen 1.4.7