From: Dejan L. <dlo...@us...> - 2004-06-10 21:59:32
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23066/rtk Modified Files: PriorityQueue.h Log Message: Index: PriorityQueue.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/PriorityQueue.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PriorityQueue.h 6 Jun 2004 15:57:38 -0000 1.1 --- PriorityQueue.h 10 Jun 2004 21:59:24 -0000 1.2 *************** *** 45,49 **** #include "Mutex.h" ! #include "Slist.h" // for SLNode struct //--------------------------------------------------------------------------- --- 45,49 ---- #include "Mutex.h" ! #include "SList.h" // for SLNode struct //--------------------------------------------------------------------------- *************** *** 59,63 **** struct _PriorityNode *next; /// Pointer to next node QueueNode *element; /// Element to last QueueNode with given priority ! int priority; /// Priority of given node } PriorityNode; --- 59,63 ---- struct _PriorityNode *next; /// Pointer to next node QueueNode *element; /// Element to last QueueNode with given priority ! unsigned char priority; /// Priority of given node } PriorityNode; *************** *** 82,86 **** * @param sort is order ascendencig or descendencing */ ! PriorityQueue(bool sort=SORT_ASC): _sort(sort),_count(0), _head(0), _tail(0), _free_func(0) { } // --------- DESTRUCTORS ----------------------------------- --- 82,87 ---- * @param sort is order ascendencig or descendencing */ ! PriorityQueue(bool sort=SORT_ASC): _sort(sort),_priority_head(0) ! ,_count(0), _head(0), _tail(0), _free_func(0), _mutex(0) { } // --------- DESTRUCTORS ----------------------------------- *************** *** 108,111 **** --- 109,117 ---- FreeDataFunc GetFreeDataFunc() { return _free_func; } + /** + * Get Mutex from PriorityQueue + */ + + Mutex* GetMutex() { return _mutex; } // --------- SET METHODS ----------------------------------- *************** *** 116,123 **** void SetFreeDataFunc(FreeDataFunc func) { _free_func = func; } // --------- OTHER METHODS --------------------------------- /** ! * Clears the PriorityQueue. This will call 'Free Data Handler' */ void Clear(); --- 122,135 ---- void SetFreeDataFunc(FreeDataFunc func) { _free_func = func; } + /** + * Set mutex for PriorityQueue, if mutex is NULL then mutex is disabled + */ + void SetMutex(Mutex* mutex) { _mutex = mutex; } + // --------- OTHER METHODS --------------------------------- /** ! * Clears the PriorityQueue. This wi ! ll call 'Free Data Handler' */ void Clear(); *************** *** 130,134 **** * number with SORT_ASC will have the higest priority) */ ! bool Push(void *data, int priority); /** --- 142,146 ---- * number with SORT_ASC will have the higest priority) */ ! bool Enqueue(void *data, unsigned char priority); /** *************** *** 137,141 **** * @return Data assigned to removed element, or NULL on error */ ! void *Pop(); /** --- 149,153 ---- * @return Data assigned to removed element, or NULL on error */ ! void *Dequeue(); /** *************** *** 165,172 **** bool _sort; /// How priority queue is sorted QueueNode* _head; /// Pointer to _head element of the List. ! QueueNode* _tail; /// Pointer to _tail element of the List. ! PriorityNode _priority_head; /// ! FreeDataFunc _free_func; /// Free data function }; // Queue --- 177,183 ---- bool _sort; /// How priority queue is sorted QueueNode* _head; /// Pointer to _head element of the List. ! PriorityNode* _priority_head; /// Pointer to priority head_element of the list FreeDataFunc _free_func; /// Free data function + Mutex* _mutex; }; // Queue |