]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/msgqueue.h
Removed wxPG_EX_LEGACY_VALIDATORS
[wxWidgets.git] / interface / wx / msgqueue.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: msgqueue.h
e54c96f1 3// Purpose: interface of wxMessageQueue<T>
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
7c913512
FM
10
11 wxMessageQueue allows passing messages between threads.
12
13 This class should be typically used to communicate between the main and worker
14 threads. The main thread calls wxMessageQueue::Post and
15 the worker thread calls wxMessageQueue::Receive.
16
17 For this class a message is an object of arbitrary type T. Notice that
18 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.
21
23324ae1
FM
22 @nolibrary
23 @category{FIXME}
7c913512 24
e54c96f1 25 @see wxThread
23324ae1 26*/
7c913512 27class wxMessageQueue<T>
23324ae1
FM
28{
29public:
30 /**
7c913512 31 Returns @true if the object had been initialized successfully, @false
23324ae1
FM
32 if an error occurred.
33 */
328f5751 34 bool IsOk() const;
23324ae1
FM
35
36 /**
7c913512
FM
37 Add a message to this queue and signal the threads waiting for messages
38 (i.e. the threads which called wxMessageQueue::Receive or
39 wxMessageQueue::ReceiveTimeout).
23324ae1
FM
40 This method is safe to call from multiple threads in parallel.
41 */
42 wxMessageQueueError Post(T const& msg);
43
44 /**
7c913512
FM
45 Block until a message becomes available in the queue. Waits indefinitely long
46 or until an error occurs.
23324ae1
FM
47 The message is returned in @e msg.
48 */
49 wxMessageQueueError Receive(T& msg);
50
51 /**
7c913512 52 Block until a message becomes available in the queue, but no more than
4cc4bfaf
FM
53 @a timeout milliseconds has elapsed.
54 If no message is available after @a timeout milliseconds then returns
7c913512 55 @b wxMSGQUEUE_TIMEOUT.
4cc4bfaf 56 If @a timeout is 0 then checks for any messages present in the queue
7c913512 57 and returns immediately without waiting.
23324ae1
FM
58 The message is returned in @e msg.
59 */
60 wxMessageQueueError ReceiveTimeout(long timeout, T& msg);
61
62 /**
7c913512 63 Default and only constructor. Use wxMessageQueue::IsOk to check
23324ae1
FM
64 if the object was successfully initialized.
65 */
7c913512 66 wxMessageQueue();
23324ae1 67};
e54c96f1 68