]>
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 licence
7 /////////////////////////////////////////////////////////////////////////////
10 Error codes for wxMessageQueue<> operations.
12 This enum contains the possible return value of wxMessageQueue<> methods.
17 enum wxMessageQueueError
19 /// Indicates that the operation completed successfully.
20 wxMSGQUEUE_NO_ERROR
= 0,
23 Indicates that no messages were received before timeout expired.
25 This return value is only used by wxMessageQueue<>::ReceiveTimeout().
29 /// Some unexpected (and fatal) error has occurred.
34 wxMessageQueue allows passing messages between threads.
36 This class should be typically used to communicate between the main and worker
37 threads. The main thread calls wxMessageQueue::Post and the worker thread
38 calls wxMessageQueue::Receive.
41 For this class a message is an object of arbitrary type T.
43 Notice that often there is a some special message indicating that the thread
44 should terminate as there is no other way to gracefully shutdown a thread
45 waiting on the message queue.
55 class wxMessageQueue
<T
>
59 Default and only constructor.
60 Use wxMessageQueue::IsOk to check if the object was successfully initialized.
65 Remove all messages from the queue.
67 This method is meant to be called from the same thread(s) that call
68 Post() to discard any still pending requests if they became
73 wxMessageQueueError
Clear();
76 Returns @true if the object had been initialized successfully, @false
82 Add a message to this queue and signal the threads waiting for messages
83 (i.e. the threads which called wxMessageQueue::Receive or
84 wxMessageQueue::ReceiveTimeout).
86 This method is safe to call from multiple threads in parallel.
88 wxMessageQueueError
Post(T
const& msg
);
91 Block until a message becomes available in the queue.
92 Waits indefinitely long or until an error occurs.
94 The message is returned in @a msg.
96 wxMessageQueueError
Receive(T
& msg
);
99 Block until a message becomes available in the queue, but no more than
100 @a timeout milliseconds has elapsed.
102 If no message is available after @a timeout milliseconds then returns
103 @b wxMSGQUEUE_TIMEOUT.
105 If @a timeout is 0 then checks for any messages present in the queue
106 and returns immediately without waiting.
108 The message is returned in @a msg.
110 wxMessageQueueError
ReceiveTimeout(long timeout
, T
& msg
);