Reputation: 9871
I have code that runs in a background thread that looks like this:
Agent agent{...};
Consumer consumer{con, agent};
while(true) {
auto msg = consumer.receive(Message::OBJECT, ...);
...
}
The receive()
call blocks, sometimes for a long time, waiting for messages to appear in the queue.
I want to be able to somehow cancel this receive()
call from a different thread and have it either return a 'null' message, or throw an exception.
The documentation says I should be able to call OCIBreak(con->getOCIServiceContext(), ...)
, but this just blocks and never returns. Attempting to env->terminateConnection()
also blocks.
I don't want to do periodic polling; I want the receive()
call to block indefinitely until cancelled. How do I achieve this?
Upvotes: 0
Views: 9