File: Poco.ActiveMethod.html

package info (click to toggle)
poco-doc 1.3.6-1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, squeeze, stretch, wheezy
  • size: 10,076 kB
  • ctags: 9,611
  • sloc: makefile: 31
file content (108 lines) | stat: -rw-r--r-- 7,006 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Poco::ActiveMethod</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="language" content="en"/>
<meta name="date" content="2009-11-24"/>
<meta name="generator" content="PocoDoc"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<div class="header">
<h1 class="namespace"><a href="Poco.html" class="namespace">Poco</a></h1>
<h1 class="template">template &lt; class ResultType, class ArgType, class OwnerType, class StarterType = ActiveStarter &lt; OwnerType &gt; &gt;</h1>
<h1 class="symbol">class ActiveMethod</h1>
</div>
<div class="body">
<p>
<b>Library:</b> Foundation<br />
<b>Package:</b> Threading<br />
<b>Header:</b> Poco/ActiveMethod.h</p>
<h2>Description</h2>
<div class="description">
<p>An active method is a method that, when called, executes in its own thread. <a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a>'s take exactly one argument and can return a value. To pass more than one argument to the method, use a struct. The following example shows how to add an <a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a> to a class: </p>
<p></p>
<pre>class ActiveObject
{
public:
    ActiveObject():
        exampleActiveMethod(this, &amp;ActiveObject::exampleActiveMethodImpl)
    {
    }

    ActiveMethod&lt;std::string, std::string, ActiveObject&gt; exampleActiveMethod;

protected:
    std::string exampleActiveMethodImpl(const std::string&amp; arg)
    {
        ...
    }
};
</pre>
<p>And following is an example that shows how to invoke an <a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a>. </p>
<p></p>
<pre>ActiveObject myActiveObject;
ActiveResult&lt;std::string&gt; result = myActiveObject.exampleActiveMethod(&quot;foo&quot;);
...
result.wait();
std::cout &lt;&lt; result.data() &lt;&lt; std::endl;
</pre>
<p>The way an <a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a> is started can be changed by passing a StarterType template argument with a corresponding class. The default <a href="Poco.ActiveStarter.html" title="class Poco::ActiveStarter">ActiveStarter</a> starts the method in its own thread, obtained from a thread pool. </p>
<p>For an alternative implementation of StarterType, see <a href="Poco.ActiveDispatcher.html" title="class Poco::ActiveDispatcher">ActiveDispatcher</a>. </p>
<p>For methods that do not require an argument or a return value, the <a href="Poco.Void.html" title="class Poco::Void">Void</a> class can be used. </p>
</div>
<h2>Member Summary</h2>
<p><b>Member Functions: </b><a href="Poco.ActiveMethod.html#3407" title="Poco::ActiveMethod::operator()">operator</a>, <a href="Poco.ActiveMethod.html#3411" title="Poco::ActiveMethod::operator =()">operator&nbsp;=</a>, <a href="Poco.ActiveMethod.html#3413" title="Poco::ActiveMethod::swap()">swap</a></p>
<h2>Types</h2>
<h3><a name="3402">ActiveResultType</a></h3>
<p class="decl">typedef <a href="Poco.ActiveResult.html" title="class Poco::ActiveResult">ActiveResult</a> &lt; <a href="Poco.ActiveMethod.html#3401" title="Poco::ActiveMethod::ResultType">ResultType</a> &gt; <a href="Poco.ActiveMethod.html#3402" title="Poco::ActiveMethod::ActiveResultType">ActiveResultType</a>;</p>
<div class="description">
<p></p>
</div>
<h3><a name="3403">ActiveRunnableType</a></h3>
<p class="decl">typedef <a href="Poco.ActiveRunnable.html" title="class Poco::ActiveRunnable">ActiveRunnable</a> &lt; <a href="Poco.ActiveMethod.html#3401" title="Poco::ActiveMethod::ResultType">ResultType</a>, ArgType, OwnerType &gt; <a href="Poco.ActiveMethod.html#3403" title="Poco::ActiveMethod::ActiveRunnableType">ActiveRunnableType</a>;</p>
<div class="description">
<p></p>
</div>
<h3><a name="3401">ResultType</a></h3>
<p class="decl">typedef <a href="Poco.ActiveMethod.html#3401" title="Poco::ActiveMethod::ResultType">ResultType</a> (OwnerType::* Callback)(const ArgType &amp;);</p>
<div class="description">
<p></p>
</div>
<h2>Constructors</h2>
<h3><a name="3409">ActiveMethod</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;const <a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a> &amp; other<br />);</p>
<div class="description">
<p></p>
</div>
<h3><a name="3404">ActiveMethod</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;OwnerType * pOwner,<br />&nbsp;&nbsp;&nbsp;&nbsp;Callback method<br />);</p>
<div class="description">
<p>Creates an <a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a> object. </p>
</div>
<h2>Member Functions</h2>
<h3><a name="3407">operator</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.ActiveMethod.html#3402" title="Poco::ActiveMethod::ActiveResultType">ActiveResultType</a> operator () (<br />&nbsp;&nbsp;&nbsp;&nbsp;const ArgType &amp; arg<br />);</p>
<div class="description">
<p>Invokes the <a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a>. </p>
</div>
<h3><a name="3411">operator =</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a> &amp; operator = (<br />&nbsp;&nbsp;&nbsp;&nbsp;const <a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a> &amp; other<br />);</p>
<div class="description">
<p></p>
</div>
<h3><a name="3413">swap</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void swap(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.ActiveMethod.html" title="class Poco::ActiveMethod">ActiveMethod</a> &amp; other<br />);</p>
<div class="description">
<p></p>
</div>
<p class="footer">POCO C++ Libraries 1.3.6-all<br />
Copyright &copy; 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p>

</div>
</body>
</html>