[openamq-dev] Regarding amq_client_session_wait
Martin Sustrik
sustrik at imatix.com
Wed Dec 19 11:56:34 CET 2007
> This is the problem: the call to amq_client_session_wait is a blocking
> call. Blocking calls prevent me from controlling my application. How
> do I cleanly interrupt the blocking call ?
Still not sure what the problem is. In your preferred code below the
sem_wait is a blocking call. What's the difference between calling
amq_client_session_wait to wait for a message and calling sem_wait?
Martin
>>> thread_func()
>>> {
>>> semaphore sync("Unique_name");
>>> initialize_semaphore(sync, NOT_SIGNALED);
>>> amq_client_session_wait (session, sync); //non-blocking call
>>>
>>> semaphore_wait(sync);// blocks until signaled - very efficiently.
>>> if(amq_client_session_basic_arrived_count (session))
>>> {
>>> while (content && run)
>>> {
>>> // process content
>>> content = amq_client_session_basic_arrived (session);
>>> }
>>> }
>>> else
>>> {
>>> // something else happened on the sync object
>>> // perhaps the app wants the thread to shutdown,
>>> // either way, we have fallen out of the blocking call
>>> }
>>> }
More information about the openamq-dev
mailing list