Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-03

Consumer producer unit (donation to fcl)

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jorge Aldo G. de F. Junior

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 TConsumer)
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 - tfphashobjectlist)

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.

Reply by email

David Mears
to Jorge Aldo G. de F. Junior
Jorge Aldo G. de F. Junior wrote 9 lines
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 can't speak for the list in general, but I would find it useful, at least.

Reply by email