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