Mercurial > hg > Papers > 2021 > soto-prosym
view Paper/src/putSynchronizedQueue.cbc @ 0:c59202657321
init
author | soto <soto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 02 Nov 2021 06:55:58 +0900 |
parents | |
children |
line wrap: on
line source
__code putSynchronizedQueue(struct SynchronizedQueue* queue, union Data* data, __code next(...)) { Element* element = new Element(); element->data = data; element->next = NULL; Element* last = queue->last; Element* nextElement = last->next; if (last != queue->last) { goto putSynchronizedQueue(); } if (nextElement == NULL) { struct Atomic* atomic = queue->atomic; goto atomic->checkAndSet(&last->next, nextElement, element, next(...), putSynchronizedQueue); } else { // wrong last element struct Atomic* atomic = queue->atomic; goto atomic->checkAndSet(&queue->last, last, nextElement, putSynchronizedQueue, putSynchronizedQueue); } }