| CPC G06F 9/3814 (2013.01) [G06F 9/52 (2013.01)] | 19 Claims |

|
1. A method for providing a lock-free self-service queue, the method comprising:
performing, using a processor and a memory:
enqueuing, among a plurality of nodes, at least one node in the lock-free self-service queue,
wherein the plurality of nodes are linked,
wherein at least one of the plurality of nodes is configured to hold a data item or remain empty, and
wherein each of the plurality of nodes includes at least a next node pointer field, a delete flag indicator field and a data item field;
competing, by a plurality of producer threads, to append their respective nodes to a last node of the enqueued at least one node;
allowing, by the processor, only a first thread of the plurality of producer threads to append its respective node to the last node of the enqueued at least one node, wherein unsuccessful producer threads either give up or reattempt to append their nodes to a new last node of the queue;
allowing, by the processor, at least one of the plurality of producer threads to temporarily operate as a temporary consumer thread to logically delete at least one non-mark-deleted node among the plurality of nodes, wherein the at least one temporary consumer thread and others of the plurality of producer threads are concurrently executed; and
modifying the next node pointer field of the last node of the enqueued at least one node to include an address of the appended node of the first thread,
wherein, when the appended node of the first thread is a last non-mark-deleted node in the lock-free self-service queue:
one or more of the plurality of producer threads will transform into one or more temporary consumer threads; and
one of the one or more temporary consumer threads dequeues a data item included in the appended node of the first thread and modifies a value of a delete flag indicator field of the appended node of the first thread to reflect a delete status.
|