]>
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 /////////////////////////////////////////////////////////////////////////////
10 wxMessageQueue allows passing messages between threads.
12 This class should be typically used to communicate between the main and worker
13 threads. The main thread calls wxMessageQueue::Post and the worker thread
14 calls wxMessageQueue::Receive.
17 For this class a message is an object of arbitrary type T.
19 Notice that often there is a some special message indicating that the thread
20 should terminate as there is no other way to gracefully shutdown a thread
21 waiting on the message queue.
29 class wxMessageQueue
<T
>
33 Default and only constructor.
34 Use wxMessageQueue::IsOk to check if the object was successfully initialized.
39 Returns @true if the object had been initialized successfully, @false
45 Add a message to this queue and signal the threads waiting for messages
46 (i.e. the threads which called wxMessageQueue::Receive or
47 wxMessageQueue::ReceiveTimeout).
49 This method is safe to call from multiple threads in parallel.
51 wxMessageQueueError
Post(T
const& msg
);
54 Block until a message becomes available in the queue.
55 Waits indefinitely long or until an error occurs.
57 The message is returned in @a msg.
59 wxMessageQueueError
Receive(T
& msg
);
62 Block until a message becomes available in the queue, but no more than
63 @a timeout milliseconds has elapsed.
65 If no message is available after @a timeout milliseconds then returns
66 @b wxMSGQUEUE_TIMEOUT.
68 If @a timeout is 0 then checks for any messages present in the queue
69 and returns immediately without waiting.
71 The message is returned in @a msg.
73 wxMessageQueueError
ReceiveTimeout(long timeout
, T
& msg
);