| | | | Browse by category |
Article ID: 814
Last updated: 05 Feb, 2008
Problem
When using one of the Producer-Consumer classes from Threads.h++ (like RWPCValQueue ), how do I specify that there should be no upper bound on the number of items it can hold?
Cause
Normally, when constructing one of the Producer-Consumer (PC) classes, you would specify an upper bound for the number of items it can hold. If a producer tries to give the PC object more items than it can hold, the producer is blocked. Consumers are also blocked if they try to read an empty PC object. However, it is often useful not to block when overrunning the queue or stack, excepting only when reading from an empty one.
Action
If you want a PC queue or stack to only block when reading from an empty one, and not when writing too many objects into the queue or stack, construct it with the value '0', or don't specify a value (it defaults to 0.) Here are some examples:
When using one of the Producer-Consumer classes from Threads.h++ (like RWPCValQueue
Cause
Normally, when constructing one of the Producer-Consumer (PC) classes, you would specify an upper bound for the number of items it can hold. If a producer tries to give the PC object more items than it can hold, the producer is blocked. Consumers are also blocked if they try to read an empty PC object. However, it is often useful not to block when overrunning the queue or stack, excepting only when reading from an empty one.
Action
If you want a PC queue or stack to only block when reading from an empty one, and not when writing too many objects into the queue or stack, construct it with the value '0', or don't specify a value (it defaults to 0.) Here are some examples:
RWPCValQueuesuzie(5); // This constructs the queue
// with an upper limit of 5.
RWPCValQueuecurly(0); // This constructs the queue
// with no upper limit.
RWPCPtrStacksmoke; // The constructs the stack with
// no upper limit.
This article was:
Helpful |
Not helpful
Report an issue
Article ID: 814
Last updated: 05 Feb, 2008
Revision: 1
Views: 3192
Posted: 14 Feb, 1998 by
Dean J.
Updated: 05 Feb, 2008 by
Dean J.
Others in this category
Powered by KBPublisher (Knowledge base software)