Event loop processing in threads that must block



I am trying to implement a design that basically allows for the
following:

1. GTK+ app makes an API call to a library (not GTK+) on a thread that
makes no GTK+ calls on its own. There is already another thread on which
their is a main event loop running.
2. The API library provides for it's own callback registration to allow
UIs to display urgent messages.
3. While in the API, the library encounters a reason to generate an
urgent message requiring a yes/no response.
4. It invokes the apps registered callback.
5. The app needs to display a window with a message and three buttons
and not return from the callback until a response is supplied
(essentially blocks)

If I was originally is a GTK+ signal handler when I made the call to
this library, I could have enter a nested gtk_main() loop and broken out
of the inner loop with gtk_main_quit() once one of the buttons was
clicked and then returned to the API library.

Unfortunetly, some number of the time I did not initiate the API call
from a GTK+ signal handler and therefore running another main loop does
not work.

How can I detect if there is another main loop and how can I run through
it enough to allow me to essentially block the callback until the window
popup is destroyed in order to return control back to the API library?

To illustrate the flow of control I want:

evms_open_engine()
       |
       |
       |
       |
       ---------------> message_cb ()
                             |
                             |
                             |
                             |
                   create_message_window ()
                             |
                       gtk_show_widget ()
                             |
                           gtk_main ()--+
                             |          |
                             |          |
                             +----------+ 
                             |
         window is destroyed so we gtk_main_quit() 
                             |
       |---------------------+
       |   return from message_cb ()
       |
       |
    continue processing evms_open_engine()
       and then return from the API call.

-- 
regards,

Luciano Chavez

lnx1138 us ibm com          
http://sf.net/projects/evms




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]