| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> |
| <title>Actors</title> |
| <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css"> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.75.0"> |
| <link rel="home" href="../index.html" title="Chapter 1. Phoenix 2.0"> |
| <link rel="up" href="../index.html" title="Chapter 1. Phoenix 2.0"> |
| <link rel="prev" href="organization.html" title="Organization"> |
| <link rel="next" href="primitives.html" title="Primitives"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table cellpadding="2" width="100%"><tr> |
| <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> |
| <td align="center"><a href="../../../../../../index.html">Home</a></td> |
| <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> |
| <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> |
| <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> |
| <td align="center"><a href="../../../../../../more/index.htm">More</a></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="organization.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="primitives.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| <a name="phoenix.actors"></a><a class="link" href="actors.html" title="Actors">Actors</a> |
| </h2></div></div></div> |
| <p> |
| The <code class="computeroutput"><span class="identifier">Actor</span></code> is the main concept |
| behind the library. Actors are function objects. An actor can accept 0 to |
| <code class="computeroutput"><span class="identifier">PHOENIX_LIMIT</span></code> arguments. |
| </p> |
| <div class="note"><table border="0" summary="Note"> |
| <tr> |
| <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td> |
| <th align="left">Note</th> |
| </tr> |
| <tr><td align="left" valign="top"><p> |
| You can set <code class="computeroutput"><span class="identifier">PHOENIX_LIMIT</span></code>, |
| the predefined maximum arity an actor can take. By default, <code class="computeroutput"><span class="identifier">PHOENIX_LIMIT</span></code> is set to 10. |
| </p></td></tr> |
| </table></div> |
| <p> |
| Phoenix supplies an <code class="computeroutput"><span class="identifier">actor</span></code> class |
| template whose specializations model the <code class="computeroutput"><span class="identifier">Actor</span></code> |
| concept. <code class="computeroutput"><span class="identifier">actor</span></code> has one template |
| parameter, <code class="computeroutput"><span class="identifier">Eval</span></code>, that supplies |
| the smarts to evaluate the resulting function. |
| </p> |
| <pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Eval</span><span class="special">></span> |
| <span class="keyword">struct</span> <span class="identifier">actor</span> <span class="special">:</span> <span class="identifier">Eval</span> |
| <span class="special">{</span> |
| <span class="identifier">return_type</span> |
| <span class="keyword">operator</span><span class="special">()()</span> <span class="keyword">const</span><span class="special">;</span> |
| |
| <span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T0</span><span class="special">></span> |
| <span class="identifier">return_type</span> |
| <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T0</span><span class="special">&</span> <span class="identifier">_0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> |
| |
| <span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T0</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">T1</span><span class="special">></span> |
| <span class="identifier">return_type</span> |
| <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T0</span><span class="special">&</span> <span class="identifier">_0</span><span class="special">,</span> <span class="identifier">T1</span><span class="special">&</span> <span class="identifier">_1</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> |
| |
| <span class="comment">//... |
| </span><span class="special">};</span> |
| </pre> |
| <p> |
| The actor class accepts the arguments through a set of function call operators |
| for 0 to <code class="computeroutput"><span class="identifier">PHOENIX_LIMIT</span></code> arities |
| (Don't worry about the details, for now. Note, for example, that we skimp over |
| the details regarding <code class="computeroutput"><span class="identifier">return_type</span></code>). |
| The arguments are then forwarded to the actor's <code class="computeroutput"><span class="identifier">Eval</span></code> |
| for evaluation. |
| </p> |
| </div> |
| <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> |
| <td align="left"></td> |
| <td align="right"><div class="copyright-footer">Copyright © 2002-2005 Joel |
| de Guzman, Dan Marsden<p> |
| Distributed under the Boost Software License, Version 1.0. (See accompanying |
| file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) |
| </p> |
| </div></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="organization.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="primitives.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> |
| </div> |
| </body> |
| </html> |