File MPSCInbox.h
↰ Parent directory (ADS/concurrent)
An inbox that many producer threads fill and one consumer thread empties, lock-free, beyond the book: the messages to a worker of a parallel search, e.g., the nodes that the other workers send to their owner.
Definition (ADS/concurrent/MPSCInbox.h)
Detailed Description
A producer pushes a cell on a stack with a compare-and-swap on its top (the stack of Treiber); the consumer takes the whole stack at once by exchanging its top with nil, and reverses it, so that the messages of each producer come out in the order in which it sent them. take() thus costs one atomic operation however many messages there are, and the consumer never competes with the producers on single items; since the consumer only takes the whole stack, the ABA problem of the stack of Treiber cannot occur.
The contracts [see File Contract.h]: only one thread calls take(). The operations are defined in MPSCInbox.tpp.
Treiber, Systems programming: coping with parallelism, Technical Report RJ 5118, IBM Almaden Research Center, 1986
- Donato Meoli
Dipartimento di Informatica Universita’ di Pisa
by Donato Meoli
Includes
ADS/Contract.h(File Contract.h)ADS/concurrent/EventCount.h(File EventCount.h)ADS/concurrent/impl/MPSCInbox.tppatomicutilityvector