]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/msgqueue.h
added wxHeaderCtrl::OnColumnCountChanging()
[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
ba1d7a6c
FM
14 threads. The main thread calls wxMessageQueue::Post and the worker thread
15 calls wxMessageQueue::Receive.
7c913512 16
ba1d7a6c
FM
17 For this class a message is an object of arbitrary type T.
18 Notice that often there is a some special message indicating that the thread
7c913512
FM
19 should terminate as there is no other way to gracefully shutdown a thread
20 waiting on the message queue.
21
23324ae1 22 @nolibrary
ba1d7a6c 23 @category{misc}
7c913512 24
e54c96f1 25 @see wxThread
23324ae1 26*/
7c913512 27class wxMessageQueue<T>
23324ae1
FM
28{
29public:
ba1d7a6c
FM
30 /**
31 Default and only constructor.
32 Use wxMessageQueue::IsOk to check if the object was successfully initialized.
33 */
34 wxMessageQueue();
35
23324ae1 36 /**
7c913512 37 Returns @true if the object had been initialized successfully, @false
23324ae1
FM
38 if an error occurred.
39 */
328f5751 40 bool IsOk() const;
23324ae1
FM
41
42 /**
7c913512
FM
43 Add a message to this queue and signal the threads waiting for messages
44 (i.e. the threads which called wxMessageQueue::Receive or
45 wxMessageQueue::ReceiveTimeout).
ba1d7a6c 46
23324ae1
FM
47 This method is safe to call from multiple threads in parallel.
48 */
49 wxMessageQueueError Post(T const& msg);
50
51 /**
ba1d7a6c
FM
52 Block until a message becomes available in the queue.
53 Waits indefinitely long or until an error occurs.
54
55 The message is returned in @a msg.
23324ae1
FM
56 */
57 wxMessageQueueError Receive(T& msg);
58
59 /**
7c913512 60 Block until a message becomes available in the queue, but no more than
4cc4bfaf 61 @a timeout milliseconds has elapsed.
ba1d7a6c 62
4cc4bfaf 63 If no message is available after @a timeout milliseconds then returns
7c913512 64 @b wxMSGQUEUE_TIMEOUT.
ba1d7a6c 65
4cc4bfaf 66 If @a timeout is 0 then checks for any messages present in the queue
7c913512 67 and returns immediately without waiting.
23324ae1 68
ba1d7a6c 69 The message is returned in @a msg.
23324ae1 70 */
ba1d7a6c 71 wxMessageQueueError ReceiveTimeout(long timeout, T& msg);
23324ae1 72};
e54c96f1 73