priority_list.h

Go to the documentation of this file.
00001 #ifndef _CP_PRIORITY_LIST_H
00002 #define _CP_PRIORITY_LIST_H
00003 
00009 #include "common.h"
00010 
00011 __BEGIN_DECLS
00012 
00013 #include "config.h"
00014 
00015 #include "collection.h"
00016 #include "linked_list.h"
00017 
00018 #define PRIORITY_LIST_IMMEDIATE 1
00019 #define PRIORITY_LIST_NORMAL    2
00020 
00040 typedef CPROPS_DLL struct _cp_priority_list
00041 {
00042     cp_list *immediate;         
00043     cp_list **normal;           
00045     int *weight;                
00046     int normal_priority_queues; 
00048     int distribution_counter;   
00049     int cycle_position;         
00050     int mode;                   
00051     cp_thread txowner;          
00052     cp_compare_fn compare_fn;
00053 
00054     int item_count;             
00056     cp_lock *lock;              
00057     int txtype;                 
00058 } cp_priority_list;
00059 
00060 
00064 //void cp_priority_list_destroy_internal(cp_priority_list *list);
00065 
00073 #define cp_priority_list_create(immediate, normal_priorities, weights) \
00074     cp_priority_list_create_by_option(immediate, normal_priorities, weights, \
00075                         NULL, NULL, NULL, COLLECTION_MODE_MULTIPLE_VALUES)
00076 
00087 CPROPS_DLL
00088 cp_priority_list *
00089     cp_priority_list_create_by_option(int immediate, 
00090                                       int normal_priority_queues, 
00091                                       int *weights, 
00092                                       cp_compare_fn compare_fn, 
00093                                       cp_copy_fn copy_fn, 
00094                                       cp_destructor_fn item_destructor,
00095                                       int mode);
00096 
00100 CPROPS_DLL
00101 void cp_priority_list_destroy(cp_priority_list *list);
00102 //#define cp_priority_list_destroy(list) cp_priority_list_destroy_by_option((list), (list)->mode)
00103 
00107 CPROPS_DLL
00108 void cp_priority_list_destroy_by_option(cp_priority_list *list, int option);
00109 
00121 CPROPS_DLL
00122 void *cp_priority_list_insert(cp_priority_list *list, void *item, int priority);
00123 
00136 CPROPS_DLL
00137 void *cp_priority_list_insert_by_option(cp_priority_list *list, void *item, int priority, int mode);
00138 
00145 //void *cp_priority_list_get_next(cp_priority_list *list);
00146 #define cp_priority_list_get_next(l) cp_priority_list_get_next_by_option((l), (l)->mode)
00147 
00154 CPROPS_DLL
00155 void *cp_priority_list_get_next_by_option(cp_priority_list *list, int mode);
00156 
00163 CPROPS_DLL
00164 int cp_priority_list_is_empty(cp_priority_list *list);
00165 
00166 
00170 #define cp_priority_list_rdlock(list) cp_priority_list_lock(list, COLLECTION_LOCK_READ)
00171 
00175 #define cp_priority_list_wrlock(list) cp_priority_list_lock(list, COLLECTION_LOCK_WRITE)
00176 
00183 CPROPS_DLL
00184 int cp_priority_list_lock(cp_priority_list *list, int lock_mode);
00185 
00189 CPROPS_DLL
00190 int cp_priority_list_unlock(cp_priority_list *list);
00191 
00197 CPROPS_DLL
00198 long cp_priority_list_item_count(cp_priority_list *list);
00199 
00200 __END_DECLS
00201 
00203 #endif 
00204 

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