]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/msgqueue.h
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     interface of wxMessageQueue<T> 
   4 // Author:      wxWidgets team 
   6 // Licence:     wxWindows license 
   7 ///////////////////////////////////////////////////////////////////////////// 
  11     wxMessageQueue allows passing messages between threads. 
  13     This class should be typically used to communicate between the main and worker 
  14     threads. The main thread calls wxMessageQueue::Post and the worker thread 
  15     calls wxMessageQueue::Receive. 
  17     For this class a message is an object of arbitrary type T. 
  18     Notice that often there is a some special message indicating that the thread 
  19     should terminate as there is no other way to gracefully shutdown a thread 
  20     waiting on the message queue. 
  27 class wxMessageQueue
<T
> 
  31         Default and only constructor. 
  32         Use wxMessageQueue::IsOk to check if the object was successfully initialized. 
  37         Returns @true if the object had been initialized successfully, @false 
  43         Add a message to this queue and signal the threads waiting for messages 
  44         (i.e. the threads which called wxMessageQueue::Receive or 
  45         wxMessageQueue::ReceiveTimeout). 
  47         This method is safe to call from multiple threads in parallel. 
  49     wxMessageQueueError 
Post(T 
const& msg
); 
  52         Block until a message becomes available in the queue. 
  53         Waits indefinitely long or until an error occurs. 
  55         The message is returned in @a msg. 
  57     wxMessageQueueError 
Receive(T
& msg
); 
  60         Block until a message becomes available in the queue, but no more than 
  61         @a timeout milliseconds has elapsed. 
  63         If no message is available after @a timeout milliseconds then returns 
  64         @b wxMSGQUEUE_TIMEOUT. 
  66         If @a timeout is 0 then checks for any messages present in the queue 
  67         and returns immediately without waiting. 
  69         The message is returned in @a msg. 
  71     wxMessageQueueError 
ReceiveTimeout(long timeout
, T
& msg
);