diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-05-09 21:31:16 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-05-09 21:31:16 +1000 |
commit | c475d69a9cbf8d2796904140dbf0f2d9d1d1220f (patch) | |
tree | 1719873eef612dd70816c9895cb78c06e9e02f20 /src/gqueue/gqueue.c | |
parent | cf5867b33d76d775782412d74733d221136af556 (diff) | |
download | uGFX-c475d69a9cbf8d2796904140dbf0f2d9d1d1220f.tar.gz uGFX-c475d69a9cbf8d2796904140dbf0f2d9d1d1220f.tar.bz2 uGFX-c475d69a9cbf8d2796904140dbf0f2d9d1d1220f.zip |
New gqueue calls to allow inserting an object into the queue at an arbitrary location.
Diffstat (limited to 'src/gqueue/gqueue.c')
-rw-r--r-- | src/gqueue/gqueue.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/gqueue/gqueue.c b/src/gqueue/gqueue.c index 8540bcea..45ca6fce 100644 --- a/src/gqueue/gqueue.c +++ b/src/gqueue/gqueue.c @@ -87,6 +87,30 @@ void _gqueueDeinit(void) pqueue->tail = pitem; } + void gfxQueueASyncInsert(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQueueASyncItem *pafter) { + gfxSystemLock(); + gfxQueueASyncInsertI(pqueue, pitem, pafter); + gfxSystemUnlock(); + } + void gfxQueueASyncInsertI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQueueASyncItem *pafter) { + if (!pitem) return; // Safety + + if (pafter && gfxQueueASyncIsInI(pqueue, pafter)) { + pitem->next = pafter->next; + pafter->next = pitem; + if (pqueue->tail == pafter) + pqueue->tail = pitem; + } else { + pitem->next = 0; + if (!pqueue->head) { + pqueue->head = pqueue->tail = pitem; + } else { + pqueue->tail->next = pitem; + pqueue->tail = pitem; + } + } + } + void gfxQueueASyncRemove(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) { gfxSystemLock(); gfxQueueASyncRemoveI(pqueue, pitem); @@ -201,6 +225,30 @@ void _gqueueDeinit(void) gfxSemSignalI(&pqueue->sem); } + void gfxQueueGSyncInsert(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter) { + gfxSystemLock(); + gfxQueueGSyncInsertI(pqueue, pitem, pafter); + gfxSystemUnlock(); + } + void gfxQueueGSyncInsertI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter) { + if (!pitem) return; // Safety + + if (pafter && gfxQueueGSyncIsInI(pqueue, pafter)) { + pitem->next = pafter->next; + pafter->next = pitem; + if (pqueue->tail == pafter) + pqueue->tail = pitem; + } else { + pitem->next = 0; + if (!pqueue->head) { + pqueue->head = pqueue->tail = pitem; + } else { + pqueue->tail->next = pitem; + pqueue->tail = pitem; + } + } + } + void gfxQueueGSyncRemove(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) { gfxSystemLock(); gfxQueueGSyncRemoveI(pqueue, pitem); @@ -312,6 +360,33 @@ void _gqueueDeinit(void) return gfxSemWait(&pitem->sem, ms); } + bool_t gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms) { + if (!pitem) return; // Safety + gfxSemInit(&pitem->sem, 0, 1); + + gfxSystemLock(); + if (pafter && gfxQueueGSyncIsInI(pqueue, pafter)) { + pitem->next = pafter->next; + pafter->next = pitem; + if (pqueue->tail == pafter) + pqueue->tail = pitem; + } else { + pitem->next = 0; + if (!pqueue->head) { + pqueue->head = pqueue->tail = pitem; + } else { + pqueue->tail->next = pitem; + pqueue->tail = pitem; + } + } + gfxSystemUnlock(); + + gfxSemSignal(&pqueue->sem); + + return gfxSemWait(&pitem->sem, ms); + + } + void gfxQueueFSyncRemove(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem) { gfxQueueFSyncItem *pi; |