Add I class rouitines to GQUEUE

ugfx_release_2.6
inmarket 2014-03-03 07:38:57 +10:00
parent 4b167f5624
commit 17f1f9d799
2 changed files with 109 additions and 59 deletions

View File

@ -22,47 +22,64 @@
gfxQueueASyncItem *gfxQueueASyncGet(gfxQueueASync *pqueue) {
gfxQueueASyncItem *pi;
// This is just a shortcut to speed execution
if (!pqueue->head)
return 0;
gfxSystemLock();
if ((pi = pqueue->head))
pqueue->head = pi->next;
pi->next = 0;
pi = gfxQueueASyncGetI(pqueue);
gfxSystemUnlock();
return pi;
}
gfxQueueASyncItem *gfxQueueASyncGetI(gfxQueueASync *pqueue) {
gfxQueueASyncItem *pi;
if ((pi = pqueue->head)) {
pqueue->head = pi->next;
pi->next = 0;
}
return pi;
}
void gfxQueueASyncPut(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
pitem->next = 0;
gfxSystemLock();
gfxQueueASyncPutI(pqueue, pitem);
gfxSystemUnlock();
}
void gfxQueueASyncPutI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
pitem->next = 0;
if (!pqueue->head) {
pqueue->head = pqueue->tail = pitem;
} else {
pqueue->tail->next = pitem;
pqueue->tail = pitem;
}
gfxSystemUnlock();
}
void gfxQueueASyncPush(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
gfxSystemLock();
gfxQueueASyncPushI(pqueue, pitem);
gfxSystemUnlock();
}
void gfxQueueASyncPushI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
pitem->next = pqueue->head;
pqueue->head = pitem;
if (!pitem->next)
pqueue->tail = pitem;
gfxSystemUnlock();
}
void gfxQueueASyncRemove(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
gfxSystemLock();
gfxQueueASyncRemoveI(pqueue, pitem);
gfxSystemUnlock();
}
void gfxQueueASyncRemoveI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) {
gfxQueueASyncItem *pi;
if (!pitem)
return;
gfxSystemLock();
if (pqueue->head) {
if (pqueue->head == pitem) {
pqueue->head = pitem->next;
@ -79,25 +96,24 @@
}
}
}
gfxSystemUnlock();
}
bool_t gfxQueueASyncIsEmpty(gfxQueueASync *pqueue) {
return pqueue->head == 0;
}
bool_t gfxQueueASyncIsIn(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem) {
gfxQueueASyncItem *pi;
bool_t res;
gfxSystemLock();
for(pi = pqueue->head; pi; pi = pi->next) {
if (pi == pitem) {
gfxSystemUnlock();
return TRUE;
}
}
res = gfxQueueASyncIsInI(pqueue, pitem);
gfxSystemUnlock();
return res;
}
bool_t gfxQueueASyncIsInI(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem) {
gfxQueueASyncItem *pi;
for(pi = pqueue->head; pi; pi = pi->next) {
if (pi == pitem)
return TRUE;
}
return FALSE;
}
#endif
@ -124,38 +140,44 @@
}
void gfxQueueGSyncPut(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) {
pitem->next = 0;
gfxSystemLock();
gfxQueueGSyncPutI(pqueue, pitem);
gfxSystemUnlock();
}
void gfxQueueGSyncPutI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) {
pitem->next = 0;
if (!pqueue->head) {
pqueue->head = pqueue->tail = pitem;
} else {
pqueue->tail->next = pitem;
pqueue->tail = pitem;
}
gfxSystemUnlock();
gfxSemSignal(&pqueue->sem);
gfxSemSignalI(&pqueue->sem);
}
void gfxQueueGSyncPush(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) {
gfxSystemLock();
gfxQueueGSyncPushI(pqueue, pitem);
gfxSystemUnlock();
}
void gfxQueueGSyncPushI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) {
pitem->next = pqueue->head;
pqueue->head = pitem;
if (!pitem->next)
pqueue->tail = pitem;
gfxSystemUnlock();
gfxSemSignal(&pqueue->sem);
gfxSemSignalI(&pqueue->sem);
}
void gfxQueueGSyncRemove(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) {
gfxSystemLock();
gfxQueueGSyncRemoveI(pqueue, pitem);
gfxSystemUnlock();
}
void gfxQueueGSyncRemoveI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) {
gfxQueueGSyncItem *pi;
if (!pitem)
return;
gfxSystemLock();
if (pqueue->head) {
if (pqueue->head == pitem) {
pqueue->head = pitem->next;
@ -172,25 +194,24 @@
}
}
}
gfxSystemUnlock();
}
bool_t gfxQueueGSyncIsEmpty(gfxQueueGSync *pqueue) {
return pqueue->head == 0;
}
bool_t gfxQueueGSyncIsIn(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem) {
gfxQueueGSyncItem *pi;
bool_t res;
gfxSystemLock();
for(pi = pqueue->head; pi; pi = pi->next) {
if (pi == pitem) {
gfxSystemUnlock();
return TRUE;
}
}
res = gfxQueueGSyncIsInI(pqueue, pitem);
gfxSystemUnlock();
return res;
}
bool_t gfxQueueGSyncIsInI(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem) {
gfxQueueGSyncItem *pi;
for(pi = pqueue->head; pi; pi = pi->next) {
if (pi == pitem)
return TRUE;
}
return FALSE;
}
#endif
@ -213,7 +234,7 @@
pi->next = 0;
gfxSystemUnlock();
gfxSemSignalI(&pi->sem);
gfxSemSignal(&pi->sem);
gfxSemDestroy(&pi->sem);
return pi;
@ -281,25 +302,24 @@
gfxSystemUnlock();
}
bool_t gfxQueueFSyncIsEmpty(gfxQueueFSync *pqueue) {
return pqueue->head == 0;
}
bool_t gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem) {
gfxQueueASyncItem *pi;
bool_t res;
gfxSystemLock();
for(pi = pqueue->head; pi; pi = pi->next) {
if (pi == pitem) {
gfxSystemUnlock();
return TRUE;
}
}
res = gfxQueueFSyncIsInI(pqueue, pitem);
gfxSystemUnlock();
return res;
}
bool_t gfxQueueFSyncIsInI(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem) {
gfxQueueASyncItem *pi;
for(pi = pqueue->head; pi; pi = pi->next) {
if (pi == pitem)
return TRUE;
}
return FALSE;
}
#endif
#endif /* GFX_USE_GQUEUE */

View File

@ -105,10 +105,13 @@ void gfxQueueFSyncInit(gfxQueueFSync *pqueue);
* @param[in] ms The maxmimum time to wait for an item. For ASync queues this parameter is
* not specified as TIME_IMMEDIATE is assumed.
*
* @note The routines ending in "I" are interrupt/system/iclass level routines.
*
* @api
* @{
*/
gfxQueueASyncItem *gfxQueueASyncGet(gfxQueueASync *pqueue);
gfxQueueASyncItem *gfxQueueASyncGetI(gfxQueueASync *pqueue);
gfxQueueGSyncItem *gfxQueueGSyncGet(gfxQueueGSync *pqueue, delaytime_t ms);
gfxQueueFSyncItem *gfxQueueFSyncGet(gfxQueueFSync *pqueue, delaytime_t ms);
/* @} */
@ -124,12 +127,15 @@ gfxQueueFSyncItem *gfxQueueFSyncGet(gfxQueueFSync *pqueue, delaytime_t ms);
* @note FSync: Use a delay time of TIME_IMMEDIATE if you don't want to wait until the
* item is removed from the queue. Note that even if the timeout occurs - the item
* remains in the queue.
* @note The routines ending in "I" are interrupt/system/iclass level routines.
*
* @api
* @{
*/
void gfxQueueASyncPut(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueASyncPutI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueGSyncPut(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
void gfxQueueGSyncPutI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
bool_t gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms);
/* @} */
@ -141,6 +147,7 @@ bool_t gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delayti
* @{
*/
#define gfxQueueASyncPop(pqueue) gfxQueueASyncGet(pqueue)
#define gfxQueueASyncPopI(pqueue) gfxQueueASyncGetI(pqueue)
#define gfxQueueGSyncPop(pqueue, ms) gfxQueueGSyncGet(pqueue, ms)
#define gfxQueueFSyncPop(pqueue, ms) gfxQueueFSyncGet(pqueue, ms)
/* @} */
@ -156,12 +163,15 @@ bool_t gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delayti
* @note FSync: Use a delay time of TIME_IMMEDIATE if you don't want to wait until the
* item is removed from the queue. Note that even if the timeout occurs - the item
* remains in the queue.
* @note The routines ending in "I" are interrupt/system/iclass level routines.
*
* @api
* @{
*/
void gfxQueueASyncPush(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueASyncPushI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueGSyncPush(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
void gfxQueueGSyncPushI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
bool_t gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms);
/* @} */
@ -175,12 +185,15 @@ bool_t gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delayt
* @note If the item isn't in the queue the routine just returns.
* @note If a process is waiting on the Put/Push operation for the item, that process
* will be signaled.
* @note The routines ending in "I" are interrupt/system/iclass level routines.
*
* @api
* @{
*/
void gfxQueueASyncRemove(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueASyncRemoveI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueGSyncRemove(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
void gfxQueueGSyncRemoveI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
void gfxQueueFSyncRemove(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem);
/* @} */
@ -190,12 +203,17 @@ void gfxQueueFSyncRemove(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem);
*
* @param[in] pqueue A pointer to the queue
*
* @note The routines ending in "I" are interrupt/system/iclass level routines.
*
* @api
* @{
*/
bool_t gfxQueueASyncIsEmpty(gfxQueueASync *pqueue);
bool_t gfxQueueGSyncIsEmpty(gfxQueueGSync *pqueue);
bool_t gfxQueueFSyncIsEmpty(gfxQueueFSync *pqueue);
#define gfxQueueASyncIsEmpty(pqueue) (pqueue->head == 0)
#define gfxQueueASyncIsEmptyI(pqueue) (pqueue->head == 0)
#define gfxQueueGSyncIsEmpty(pqueue) (pqueue->head == 0)
#define gfxQueueGSyncIsEmptyI(pqueue) (pqueue->head == 0)
#define gfxQueueFSyncIsEmpty(pqueue) (pqueue->head == 0)
#define gfxQueueFSyncIsEmptyI(pqueue) (pqueue->head == 0)
/* @} */
/**
@ -206,13 +224,17 @@ bool_t gfxQueueFSyncIsEmpty(gfxQueueFSync *pqueue);
* @param[in] pitem A pointer to the queue item
*
* @note This operation may be expensive.
* @note The routines ending in "I" are interrupt/system/iclass level routines.
*
* @api
* @{
*/
bool_t gfxQueueASyncIsIn(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem);
bool_t gfxQueueASyncIsInI(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem);
bool_t gfxQueueGSyncIsIn(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem);
bool_t gfxQueueGSyncIsInI(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem);
bool_t gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem);
bool_t gfxQueueFSyncIsInI(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem);
/* @} */
/**
@ -226,13 +248,17 @@ bool_t gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem);
* @note As that item is still on the queue, it should be treated as read-only. It could
* also be removed from the queue at any time by another thread (thereby altering the
* queue item).
* @note The routines ending in "I" are interrupt/system/iclass level routines.
*
* @api
* @{
*/
#define gfxQueueASyncPeek(pqueue) ((const gfxQueueASyncItem *)((pqueue)->head))
#define gfxQueueASyncPeekI(pqueue) ((const gfxQueueASyncItem *)((pqueue)->head))
#define gfxQueueGSyncPeek(pqueue) ((const gfxQueueGSyncItem *)((pqueue)->head))
#define gfxQueueGSyncPeekI(pqueue) ((const gfxQueueGSyncItem *)((pqueue)->head))
#define gfxQueueFSyncPeek(pqueue) ((const gfxQueueFSyncItem *)((pqueue)->head))
#define gfxQueueFSyncPeekI(pqueue) ((const gfxQueueFSyncItem *)((pqueue)->head))
/* @} */
/**
@ -246,13 +272,17 @@ bool_t gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem);
* @note As that item is still on the queue, it should be treated as read-only. It could
* also be removed from the queue at any time by another thread (thereby altering the
* queue item).
* @note The routines ending in "I" are interrupt/system/iclass level routines.
*
* @api
* @{
*/
#define gfxQueueASyncNext(pitem) ((const gfxQueueASyncItem *)((pitem)->next))
#define gfxQueueASyncNextI(pitem) ((const gfxQueueASyncItem *)((pitem)->next))
#define gfxQueueGSyncNext(pitem) ((const gfxQueueGSyncItem *)((pitem)->next))
#define gfxQueueGSyncNextI(pitem) ((const gfxQueueGSyncItem *)((pitem)->next))
#define gfxQueueFSyncNext(pitem) ((const gfxQueueFSyncItem *)((pitem)->next))
#define gfxQueueFSyncNextI(pitem) ((const gfxQueueFSyncItem *)((pitem)->next))
/* @} */
#ifdef __cplusplus