]>
git.saurik.com Git - wxWidgets.git/blob - interface/msgqueue.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxMessageQueue<T>
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.
29 class wxMessageQueue
<T
>
33 Returns @true if the object had been initialized successfully, @false
39 Add a message to this queue and signal the threads waiting for messages
40 (i.e. the threads which called wxMessageQueue::Receive or
41 wxMessageQueue::ReceiveTimeout).
42 This method is safe to call from multiple threads in parallel.
44 wxMessageQueueError
Post(T
const& msg
);
47 Block until a message becomes available in the queue. Waits indefinitely long
48 or until an error occurs.
49 The message is returned in @e msg.
51 wxMessageQueueError
Receive(T
& msg
);
54 Block until a message becomes available in the queue, but no more than
55 @a timeout milliseconds has elapsed.
56 If no message is available after @a timeout milliseconds then returns
57 @b wxMSGQUEUE_TIMEOUT.
58 If @a timeout is 0 then checks for any messages present in the queue
59 and returns immediately without waiting.
60 The message is returned in @e msg.
62 wxMessageQueueError
ReceiveTimeout(long timeout
, T
& msg
);
65 Default and only constructor. Use wxMessageQueue::IsOk to check
66 if the object was successfully initialized.