Reputation:
I am currently trying to design a piece of screen-capture software.
One design question I am having is I want to know if it is possible to eliminate the circular dependency between the PictureGetter and the PictureProcessor.
The getter needs to call the processor to tell it that a picture is ready. The processor has to tell the getter that it is done processing the picture.
These two elements are in separate threads and cannot share data directly(and I do not want to share data), they can only add member calls of the target object onto that object's queue queue. (eg queue.add(&PictureProccessor::sendPicture,picture)
)
Upvotes: 3
Views: 422
Reputation: 231
Maybe create a 1 element queue from getter to processor.
Getter sends pic. Queue is empty when processor is done.
Upvotes: 0
Reputation: 33655
Use a resource manager, make both aware of that. The getter can enqueue a picture to be processed with the manager, the manager can then have a "pool" of processors of which one can be used for processing. Processor can enqueue the processed picture with the resource manager which can then notify to the appropriate getter. I'm sure there's some funky name for this pattern, but cannot recall it right now.
Upvotes: 6