📄 async.message.html
字号:
<html><!-- #BeginTemplate "/Templates/tmpl.dwt" --><head><!-- #BeginEditable "doctitle" --> <title>PTypes: multithreading: message</title><!-- #EndEditable --> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link rel="stylesheet" href="styles.css"></head><body bgcolor="#FFFFFF" leftmargin="40" marginwidth="40"><p><a href="../index.html"><img src="title-1.7.gif" width="213" height="34" alt="C++ Portable Types Library (PTypes) Version 1.7" border="0"></a> <hr noshade><!-- #BeginEditable "body" --> <p class="hpath"><a href="index.html">Top</a>: <a href="async.html">Multithreading</a>: message</p><blockquote> <pre class="lang">#include <pasync.h>message::message(int id, int param = 0);int message::id;int message::result;int message::param;</pre></blockquote><p>A message object or an object of a derived class can be used to post data to a message queue (<a href="async.msgqueue.html">msgqueue</a>). Since all messages in the given queue are processed by one handler, they have to be distinguished by some ID. Like in Windows, you define your own message IDs in the range MSG_USER to MSG_USER_MAX. A simple message can also contain an additional parameter of type <span class="lang">int</span>.</p><p>For more complex message structures you can define classes derived from <span class="lang">message </span> - the message queue manager can work with any descendant class as well.</p><p><b>IMPORTANT NOTES</b>: (1) a message object should always be constructed dynamically, i.e. using operator <span class="lang">new</span>; (2) a message object is always destroyed by the queue manager after it has been processed; (3) a message object can be sent and processed only once.</p><p><span class="def">message::message(int id, int param = 0)</span> constructs a message object and assigns <span class="lang">id</span> and <span class="lang">param</span> fields. param is an additional field that can be used in your application at your own discretion.</p><p><span class="def">int message::id</span> -- this field contains a message ID assigned through the constructor.</p><p><span class="def">int message::result</span> -- through this field a message handler can return some simple answer to the sender of this message.</p><p><span class="def">int message::param</span> contains the optional parameter.</p><p class="seealso">See also: <a href="async.msgqueue.html">msgqueue</a>, <a href="async.examples.html">Examples</a></p><!-- #EndEditable --><hr size="1"><a href="../index.html" class="ns">PTypes home</a></body><!-- #EndTemplate --></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -