]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/msgqueue.tex
no changes, just come cleanup and more comments
[wxWidgets.git] / docs / latex / wx / msgqueue.tex
CommitLineData
e815120e
VZ
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
2%% Name: msgqueue.tex\r
3%% Purpose: wxMessageQueue\r
4%% Author: Evgeniy Tarassov\r
5%% Created: 2007-10-31\r
6%% RCS-ID: $Id: $\r
7%% Copyright: (C) 2007 TT-Solutions SARL\r
8%% License: wxWindows license\r
9%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
10\r
11\section{\class{wxMessageQueue<T>}}\label{wxmessagequeue}\r
12\r
13wxMessageQueue allows passing messages between threads.\r
14\r
15This class should be typically used to communicate between the main and worker\r
16threads. The main thread calls \helpref{Post()}{wxmessagequeuepost} and\r
17the worker thread calls \helpref{Receive()}{wxmessagequeuereceive}.\r
18\r
19For this class a message is an object of arbitrary type T. Notice that\r
20often there is a some special message indicating that the thread\r
21should terminate as there is no other way to gracefully shutdown a thread\r
22waiting on the message queue.\r
23\r
24\wxheading{Derived from}\r
25\r
26None.\r
27\r
28\wxheading{Include files}\r
29\r
30<wx/msgqueue.h>\r
31\r
32\wxheading{Library}\r
33\r
34None, this class implementation is entirely header-based.\r
35\r
36\wxheading{See also}\r
37\r
38\helpref{wxThread}{wxthread}\r
39\r
40\r
41\latexignore{\rtfignore{\wxheading{Members}}}\r
42\r
43\r
44\membersection{wxMessageQueue::wxMessageQueue}\label{wxmessagequeuector}\r
45\r
46\func{}{wxMessageQueue}{\void}\r
47\r
48Default and only constructor. Use \helpref{IsOk}{wxmessagequeueisok} to check\r
49if the object was successfully initialized.\r
50\r
51\r
52\membersection{wxMessageQueue::IsOk}\label{wxmessagequeueisok}\r
53\r
54\constfunc{bool }{IsOk}{\void}\r
55\r
56Returns {\tt true} if the object had been initialized successfully, {\tt false} \r
57if an error occurred.\r
58\r
59\r
60\membersection{wxMessageQueue::Post}\label{wxmessagequeuepost}\r
61\r
62\func{wxMessageQueueError }{Post}{\param{T const\&}{ msg}}\r
63\r
64Add a message to this queue and signal the threads waiting for messages\r
65(i.e. the threads which called \helpref{Receive()}{wxmessagequeuereceive} or\r
66\helpref{ReceiveTimeout()}{wxmessagequeuereceivetimeout}).\r
67\r
68This method is safe to call from multiple threads in parallel.\r
69\r
70\wxheading{Return value}\r
71\r
72One of:\r
73\r
74\twocolwidtha{7cm}\r
75\begin{twocollist}\itemsep=0pt\r
76\twocolitem{{\bf wxMSGQUEUE\_NO\_ERROR}}{There was no error.}\r
77\twocolitem{{\bf wxMSGQUEUE\_MISC\_ERROR}}{A fatal error has occured.}\r
78\end{twocollist}\r
79\r
80\r
81\membersection{wxMessageQueue::Receive}\label{wxmessagequeuereceive}\r
82\r
83\func{wxMessageQueueError }{Receive}{\param{T\&}{ msg}}\r
84\r
85Block until a message becomes available in the queue. Waits indefinitely long\r
86or until an error occurs.\r
87\r
88The message is returned in \arg{msg}.\r
89\r
90\wxheading{Return value}\r
91\r
92One of:\r
93\r
94\twocolwidtha{7cm}\r
95\begin{twocollist}\itemsep=0pt\r
96\twocolitem{{\bf wxMSGQUEUE\_NO\_ERROR}}{A message is available.}\r
97\twocolitem{{\bf wxMSGQUEUE\_MISC\_ERROR}}{A fatal error has occured and no message returned.}\r
98\end{twocollist}\r
99\r
100\r
101\membersection{wxMessageQueue::ReceiveTimeout}\label{wxmessagequeuereceivetimeout}\r
102\r
103\func{wxMessageQueueError }{ReceiveTimeout}{\param{long}{ timeout}, \param{T\&}{ msg}}\r
104\r
105Block until a message becomes available in the queue, but no more than\r
106\arg{timeout} milliseconds has elapsed.\r
107\r
108If no message is available after \arg{timeout} milliseconds then returns\r
109{\bf wxMSGQUEUE\_TIMEOUT}.\r
110\r
111If \arg{timeout} is $0$ then checks for any messages present in the queue\r
112and returns immediately without waiting.\r
113\r
114The message is returned in \arg{msg}.\r
115\r
116\wxheading{Return value}\r
117\r
118One of:\r
119\r
120\twocolwidtha{7cm}\r
121\begin{twocollist}\itemsep=0pt\r
122\twocolitem{{\bf wxMSGQUEUE\_NO\_ERROR}}{A message is available.}\r
123\twocolitem{{\bf wxMSGQUEUE\_TIMEOUT}}{A timeout has occured. No message read.}\r
124\twocolitem{{\bf wxMSGQUEUE\_MISC\_ERROR}}{A fatal error has occured.}\r
125\end{twocollist}\r
126\r