[fpc-pascal] Consumer producer unit (donation to fcl)

Jorge Aldo G. de F. Junior jagfj80 at gmail.com
Tue Mar 1 19:50:31 CET 2011

i have implemented a small consumer x producer unit (ie: threads that
produce or consume tobjects)

it is thread safe (based around a tthreadsafequeue with signalling -
the thread can sleep/wait arbitrary timeout time while its queue is
empty waiting for the producer)

is it interesting for the fcl ?

i want to donate it, and i think it can be incremented with other functions.

currently theres the following :

TProducer (thread that produces tobjects, placing then on the queue of
a consumer)
TConsumer (thread that consumes tobjects thru a queue)
TConsumerProducer (kind of a proxy, that consumes tobjects in a side,
process them and sends then to another consumer, it inherits from
TRandomMultiplexerProducerConsumerThread (similar to the previous, but
has more than one consumer attached, it selects the next one to send
its tobjects by random)
TRoundRobinMultiplexerProducerConsumerThread (similar to the previous,
but instead of random chance, uses a round robing fashion)
TCustomAddressableMultiplexer (similar to the previous, but allows a
kind of addressability of the tobjects, selecting with consumer to
send to, by using a message address and a hashtable -

Now i am developing bus and other models (various threads sharing a
bus to send messages to each other, where each thread has an address).

but the basic implementation evolves around the consumer producer model.

More information about the fpc-pascal mailing list