libcppa
Version 0.1
|
Namespaces | |
namespace | detail |
namespace | util |
Classes | |
class | actor |
Base class for all actor implementations. More... | |
class | actor_proxy |
Represents a remote Actor. More... | |
class | any_tuple |
Describes a fixed-length tuple with elements of any type. More... | |
struct | anything |
Acts as wildcard pattern. More... | |
class | attachable |
Callback utility class. More... | |
class | channel |
Interface for all message receivers. More... | |
class | cow_ptr |
A copy-on-write smart pointer implementation. More... | |
class | deserializer |
Technology-independent deserialization interface. More... | |
class | exception |
Base class for libcppa exceptions. More... | |
class | actor_exited |
Thrown if an actor finished execution. More... | |
class | network_error |
Thrown to indicate that either an actor publishing failed or libcppa was unable to connect to a remote host. More... | |
class | bind_failure |
Thrown to indicate that an actor publishing failed because the requested port could not be used. More... | |
class | group |
A multicast group. More... | |
class | intrusive_ptr |
An intrusive, reference counting smart pointer impelementation. More... | |
class | invoke_rules_base |
Base of timed_invoke_rules and invoke_rules. More... | |
class | timed_invoke_rules |
Invoke rules with timeout. More... | |
class | invoke_rules |
Invoke rules without timeout. More... | |
class | local_actor |
Base class for local running Actors. More... | |
class | message_queue |
A message queue with many-writers-single-reader semantics. More... | |
class | object |
An abstraction class that stores an instance of an announced type. More... | |
class | primitive_variant |
An union container for primitive data types. More... | |
class | process_information |
Identifies a process. More... | |
class | ref_counted |
A (thread safe) base class for reference counted objects with an atomic reference count. More... | |
class | serializer |
Technology-independent serialization interface. More... | |
class | tuple |
A fixed-length copy-on-write tuple. More... | |
class | tuple_view |
Describes a view of an fixed-length tuple. More... | |
class | uniform_type_info |
Provides a platform independent type name and a (very primitive) kind of reflection in combination with object. More... | |
Typedefs | |
typedef intrusive_ptr< actor > | actor_ptr |
typedef intrusive_ptr< channel > | channel_ptr |
typedef intrusive_ptr< group > | group_ptr |
typedef intrusive_ptr < process_information > | process_information_ptr |
Enumerations | |
enum | primitive_type { pt_int8, pt_int16, pt_int32, pt_int64, pt_uint8, pt_uint16, pt_uint32, pt_uint64, pt_float, pt_double, pt_long_double, pt_u8string, pt_u16string, pt_u32string, pt_null } |
Functions | |
bool | announce (const std::type_info &tinfo, uniform_type_info *utype) |
template<class C , class Parent , typename... Args> | |
std::pair< C Parent::*, util::abstract_uniform_type_info < C > * > | compound_member (C Parent::*c_ptr, const Args &...args) |
template<typename T , typename... Args> | |
bool | announce (const Args &...args) |
void | link (actor_ptr &other) |
void | link (actor_ptr &&other) |
void | link (actor_ptr &lhs, actor_ptr &rhs) |
void | link (actor_ptr &&lhs, actor_ptr &rhs) |
void | link (actor_ptr &&lhs, actor_ptr &&rhs) |
void | link (actor_ptr &lhs, actor_ptr &&rhs) |
void | unlink (actor_ptr &lhs, actor_ptr &rhs) |
void | monitor (actor_ptr &whom) |
void | monitor (actor_ptr &&whom) |
void | demonitor (actor_ptr &whom) |
bool | trap_exit () |
void | trap_exit (bool new_value) |
template<scheduling_hint Hint, typename F , typename... Args> | |
actor_ptr | spawn (F &&what, const Args &...args) |
template<typename F , typename... Args> | |
actor_ptr | spawn (F &&what, const Args &...args) |
void | quit (std::uint32_t reason) |
void | receive_loop (invoke_rules &rules) |
void | receive_loop (timed_invoke_rules &rules) |
void | receive_loop (invoke_rules &&rules) |
void | receive_loop (timed_invoke_rules &&rules) |
template<typename Head , typename... Tail> | |
void | receive_loop (invoke_rules &rules, Head &&head, Tail &&...tail) |
template<typename Head , typename... Tail> | |
void | receive_loop (invoke_rules &&rules, Head &&head, Tail &&...tail) |
template<typename Statement > | |
detail::receive_while_helper < Statement > | receive_while (Statement &&stmt) |
template<typename... Args> | |
detail::do_receive_helper | do_receive (Args &&...args) |
any_tuple & | last_received () |
actor_ptr & | last_sender () |
template<typename Arg0 , typename... Args> | |
void | send (channel_ptr &whom, const Arg0 &arg0, const Args &...args) |
channel_ptr & | operator<< (channel_ptr &whom, const any_tuple &what) |
template<typename Duration , typename... Data> | |
void | future_send (actor_ptr whom, const Duration &rel_time, const Data &...data) |
void | await_all_others_done () |
void | publish (actor_ptr &whom, std::uint16_t port) |
void | publish (actor_ptr &&whom, std::uint16_t port) |
actor_ptr | remote_actor (const char *host, std::uint16_t port) |
local_actor * | self () |
constexpr const char * | primitive_type_name (primitive_type ptype) |
std::string | to_string (const process_information::node_id_type &node_id) |
const any_tuple & | receive () |
void | receive (invoke_rules &rules) |
bool | try_receive (any_tuple &msg) |
bool | try_receive (invoke_rules &rules) |
void | set_scheduler (scheduler *sched) |
scheduler * | get_scheduler () |
template<typename T > | |
std::string | to_string (const T &what) |
This is the root namespace of libcppa.
Thie cppa namespace contains all functions and classes to implement Actor based applications.
typedef intrusive_ptr<actor> cppa::actor_ptr |
A smart pointer type that manages instances of actor.
typedef intrusive_ptr<channel> cppa::channel_ptr |
A smart pointer type that manages instances of channel.
typedef intrusive_ptr<group> cppa::group_ptr |
A smart pointer type that manages instances of group.
A smart pointer type that manages instances of process_information.
void cppa::await_all_others_done | ( | ) |
Blocks execution of this actor until all other actors finished execution.
void cppa::demonitor | ( | actor_ptr & | whom | ) |
Removes a monitor from whom
.
whom | Monitored Actor. |
detail::do_receive_helper cppa::do_receive | ( | Args &&... | args | ) |
Receives messages until stmt
returns true.
Semantically equal to: do { receive(...); } while (stmt() == false);
Usage example:
int i = 0; do_receive ( on<int>() >> int_fun, on<float>() >> float_fun ) .until([&]() { return (++i >= 10); };
args | Invoke rules to handle received messages. |
until
member function. void cppa::future_send | ( | actor_ptr | whom, |
const Duration & | rel_time, | ||
const Data &... | data | ||
) |
Sends a message to whom
that is delayed by rel_time
.
whom | Receiver of the message. |
rel_time | Relative time duration to delay the message. |
data | Any number of values for the message content. |
scheduler* cppa::get_scheduler | ( | ) |
Gets the actual used scheduler implementation.
any_tuple& cppa::last_received | ( | ) |
Gets the last dequeued message from the mailbox.
actor_ptr& cppa::last_sender | ( | ) |
Gets the sender of the last received message.
void cppa::link | ( | actor_ptr & | other | ) |
Links the calling actor to other
.
other | An Actor that is related with the calling Actor. |
void cppa::link | ( | actor_ptr && | other | ) |
Links the calling actor to other
.
other | An Actor that is related with the calling Actor. |
void cppa::link | ( | actor_ptr & | lhs, |
actor_ptr & | rhs | ||
) |
Links lhs
and rhs
;.
lhs | First Actor instance. |
rhs | Second Actor instance. |
lhs != rhs
void cppa::link | ( | actor_ptr && | lhs, |
actor_ptr & | rhs | ||
) |
Links lhs
and rhs
;.
lhs | First Actor instance. |
rhs | Second Actor instance. |
lhs != rhs
void cppa::link | ( | actor_ptr && | lhs, |
actor_ptr && | rhs | ||
) |
Links lhs
and rhs
;.
lhs | First Actor instance. |
rhs | Second Actor instance. |
lhs != rhs
void cppa::link | ( | actor_ptr & | lhs, |
actor_ptr && | rhs | ||
) |
Links lhs
and rhs
;.
lhs | First Actor instance. |
rhs | Second Actor instance. |
lhs != rhs
void cppa::monitor | ( | actor_ptr & | whom | ) |
Adds a monitor to whom
.
Sends a ":Down" message to the calling Actor if whom
exited.
whom | Actor instance that should be monitored by the calling Actor. |
void cppa::monitor | ( | actor_ptr && | whom | ) |
Adds a monitor to whom
.
Sends a ":Down" message to the calling Actor if whom
exited.
whom | Actor instance that should be monitored by the calling Actor. |
channel_ptr& cppa::operator<< | ( | channel_ptr & | whom, |
const any_tuple & | what | ||
) |
Send a message to whom
.
Usage example:
self() << make_tuple(1, 2, 3);
Sends the tuple what
as a message to whom
.
whom | Receiver of the message. |
what | Content of the message. |
whom
. void cppa::publish | ( | actor_ptr & | whom, |
std::uint16_t | port | ||
) |
Publishes whom
at given port
.
The connection is automatically closed if the lifetime of whom
ends.
whom | Actor that should be published at given port . |
port | Unused TCP port. |
bind_failure |
void cppa::publish | ( | actor_ptr && | whom, |
std::uint16_t | port | ||
) |
Publishes whom
at given port
.
The connection is automatically closed if the lifetime of whom
ends.
whom | Actor that should be published at given port . |
port | Unused TCP port. |
bind_failure |
void cppa::quit | ( | std::uint32_t | reason | ) |
Finishes execution of this actor.
Cause this actor to send an exit signal to all of its linked actors, sets its state to exited
and throws actor_exited to cleanup the stack.
reason | Exit reason that will be send to linked actors. |
actor_exited |
Alias for self()->quit(reason);
const any_tuple& cppa::receive | ( | ) |
Dequeues the next message from the mailbox.
void cppa::receive | ( | invoke_rules & | rules | ) |
Dequeues the next message from the mailbox that's matched by rules
and executes the corresponding callback.
void cppa::receive_loop | ( | invoke_rules & | rules | ) |
Receives messages in an endless loop.
Semantically equal to: for (;;) { receive(rules); }
rules | Invoke rules to receive and handle messages. |
void cppa::receive_loop | ( | timed_invoke_rules & | rules | ) |
Receives messages in an endless loop.
Semantically equal to: for (;;) { receive(rules); }
rules | Invoke rules to receive and handle messages. |
void cppa::receive_loop | ( | invoke_rules && | rules | ) |
Receives messages in an endless loop.
Semantically equal to: for (;;) { receive(rules); }
rules | Invoke rules to receive and handle messages. |
void cppa::receive_loop | ( | timed_invoke_rules && | rules | ) |
Receives messages in an endless loop.
Semantically equal to: for (;;) { receive(rules); }
rules | Invoke rules to receive and handle messages. |
void cppa::receive_loop | ( | invoke_rules & | rules, |
Head && | head, | ||
Tail &&... | tail | ||
) |
Receives messages in an endless loop.
This function overload provides a simple way to define a receive loop with on-the-fly invoke_rules.
Example:
receive_loop(on<int>() >> int_fun, on<float>() >> float_fun);
void cppa::receive_loop | ( | invoke_rules && | rules, |
Head && | head, | ||
Tail &&... | tail | ||
) |
Receives messages in an endless loop.
This function overload provides a simple way to define a receive loop with on-the-fly invoke_rules.
Example:
receive_loop(on<int>() >> int_fun, on<float>() >> float_fun);
Support for rvalue references.
detail::receive_while_helper<Statement> cppa::receive_while | ( | Statement && | stmt | ) |
Receives messages as long as stmt
returns true.
Semantically equal to: while (stmt()) { receive(...); }
.
Usage example:
int i = 0; receive_while([&]() { return (++i <= 10); }) ( on<int>() >> int_fun, on<float>() >> float_fun );
stmt | Lambda expression, functor or function returning a bool . |
actor_ptr cppa::remote_actor | ( | const char * | host, |
std::uint16_t | port | ||
) |
Establish a new connection to the actor at host
on given port
.
host | Valid hostname or IP address. |
port | TCP port. |
local_actor* cppa::self | ( | ) |
Get a pointer to the current active context.
void cppa::send | ( | channel_ptr & | whom, |
const Arg0 & | arg0, | ||
const Args &... | args | ||
) |
Sends a message to whom
.
Sends the tuple { arg0, args... }
as a message to whom
.
whom | Receiver of the message. |
arg0 | First value for the message content. |
args | Any number of values for the message content. |
void cppa::set_scheduler | ( | scheduler * | sched | ) |
Sets the scheduler to sched
.
sched | A user-defined scheduler implementation. |
sched != nullptr
. std::runtime_error | if there's already a scheduler defined. |
actor_ptr cppa::spawn | ( | F && | what, |
const Args &... | args | ||
) |
Spawns a new actor that executes what
with given arguments.
Hint | Hint to the scheduler for the best scheduling strategy. |
what | Function or functor that the spawned Actor should execute. |
args | Arguments needed to invoke what . |
actor_ptr cppa::spawn | ( | F && | what, |
const Args &... | args | ||
) |
Alias for spawn<scheduled>(what, args...)
.
what | Function or functor that the spawned Actor should execute. |
args | Arguments needed to invoke what . |
std::string cppa::to_string | ( | const T & | what | ) |
Serializes a value to a string.
what | A value of an announced type. |
what
. std::string cppa::to_string | ( | const process_information::node_id_type & | node_id | ) |
Converts node_id to an hexadecimal string.
bool cppa::trap_exit | ( | ) |
Gets the trap_exit
state of the calling Actor.
true
if the Actor explicitly handles Exit messages; false
if the Actor uses the default behavior (finish execution if an Exit message with non-normal exit reason was received). void cppa::trap_exit | ( | bool | new_value | ) |
Sets the trap_exit
state of the calling Actor.
new_value | Set this to true if you want to explicitly handle Exit messages. The default is false , causing an Actor to finish execution if an Exit message with non-normal exit reason was received. |
bool cppa::try_receive | ( | any_tuple & | msg | ) |
Tries to dequeue the next message from the mailbox.
true
if a messages was dequeued; false
if the mailbox is empty bool cppa::try_receive | ( | invoke_rules & | rules | ) |
Tries to dequeue the next message from the mailbox.
true
if a messages was dequeued; false
if the mailbox is empty void cppa::unlink | ( | actor_ptr & | lhs, |
actor_ptr & | rhs | ||
) |
Unlinks lhs
and rhs
;.