]> git.saurik.com Git - wxWidgets.git/blame - interface/msgqueue.h
added test of focusing/selecting another item
[wxWidgets.git] / interface / 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/**
10 @class wxMessageQueueT
11 @wxheader{msgqueue.h}
7c913512
FM
12
13 wxMessageQueue allows passing messages between threads.
14
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.
18
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.
23
23324ae1
FM
24 @nolibrary
25 @category{FIXME}
7c913512 26
e54c96f1 27 @see wxThread
23324ae1 28*/
7c913512 29class wxMessageQueue<T>
23324ae1
FM
30{
31public:
32 /**
7c913512 33 Returns @true if the object had been initialized successfully, @false
23324ae1
FM
34 if an error occurred.
35 */
328f5751 36 bool IsOk() const;
23324ae1
FM
37
38 /**
7c913512
FM
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).
23324ae1
FM
42 This method is safe to call from multiple threads in parallel.
43 */
44 wxMessageQueueError Post(T const& msg);
45
46 /**
7c913512
FM
47 Block until a message becomes available in the queue. Waits indefinitely long
48 or until an error occurs.
23324ae1
FM
49 The message is returned in @e msg.
50 */
51 wxMessageQueueError Receive(T& msg);
52
53 /**
7c913512 54 Block until a message becomes available in the queue, but no more than
4cc4bfaf
FM
55 @a timeout milliseconds has elapsed.
56 If no message is available after @a timeout milliseconds then returns
7c913512 57 @b wxMSGQUEUE_TIMEOUT.
4cc4bfaf 58 If @a timeout is 0 then checks for any messages present in the queue
7c913512 59 and returns immediately without waiting.
23324ae1
FM
60 The message is returned in @e msg.
61 */
62 wxMessageQueueError ReceiveTimeout(long timeout, T& msg);
63
64 /**
7c913512 65 Default and only constructor. Use wxMessageQueue::IsOk to check
23324ae1
FM
66 if the object was successfully initialized.
67 */
7c913512 68 wxMessageQueue();
23324ae1 69};
e54c96f1 70