libcppa  Version 0.1
Namespaces | Classes | Typedefs | Enumerations | Functions
cppa Namespace Reference

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< actoractor_ptr
typedef intrusive_ptr< channelchannel_ptr
typedef intrusive_ptr< groupgroup_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_tuplelast_received ()
actor_ptrlast_sender ()
template<typename Arg0 , typename... Args>
void send (channel_ptr &whom, const Arg0 &arg0, const Args &...args)
channel_ptroperator<< (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_actorself ()
constexpr const char * primitive_type_name (primitive_type ptype)
std::string to_string (const process_information::node_id_type &node_id)
const any_tuplereceive ()
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)

Detailed Description

This is the root namespace of libcppa.

Thie cppa namespace contains all functions and classes to implement Actor based applications.


Typedef Documentation

A smart pointer type that manages instances of actor.

A smart pointer type that manages instances of channel.

A smart pointer type that manages instances of group.

A smart pointer type that manages instances of process_information.


Function Documentation

void cppa::await_all_others_done ( )

Blocks execution of this actor until all other actors finished execution.

Warning:
This function will cause a deadlock if called from multiple actors.
void cppa::demonitor ( actor_ptr &  whom)

Removes a monitor from whom.

Parameters:
whomMonitored Actor.
template<typename... Args>
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); };
Parameters:
argsInvoke rules to handle received messages.
Returns:
A functor providing the until member function.
template<typename Duration , typename... Data>
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.

Parameters:
whomReceiver of the message.
rel_timeRelative time duration to delay the message.
dataAny number of values for the message content.
scheduler* cppa::get_scheduler ( )

Gets the actual used scheduler implementation.

Returns:
The active scheduler (usually default constructed).
any_tuple& cppa::last_received ( )

Gets the last dequeued message from the mailbox.

Returns:
The last dequeued message from the mailbox.
Examples:
announce_example_4.cpp, and announce_example_5.cpp.
actor_ptr& cppa::last_sender ( )

Gets the sender of the last received message.

Returns:
An actor_ptr to the sender of the last received message.
void cppa::link ( actor_ptr &  other)

Links the calling actor to other.

Parameters:
otherAn Actor that is related with the calling Actor.
void cppa::link ( actor_ptr &&  other)

Links the calling actor to other.

Parameters:
otherAn Actor that is related with the calling Actor.
Support for rvalue references.

void cppa::link ( actor_ptr &  lhs,
actor_ptr &  rhs 
)

Links lhs and rhs;.

Parameters:
lhsFirst Actor instance.
rhsSecond Actor instance.
Precondition:
lhs != rhs
void cppa::link ( actor_ptr &&  lhs,
actor_ptr &  rhs 
)

Links lhs and rhs;.

Parameters:
lhsFirst Actor instance.
rhsSecond Actor instance.
Precondition:
lhs != rhs
Support for rvalue references.

void cppa::link ( actor_ptr &&  lhs,
actor_ptr &&  rhs 
)

Links lhs and rhs;.

Parameters:
lhsFirst Actor instance.
rhsSecond Actor instance.
Precondition:
lhs != rhs
Support for rvalue references.

void cppa::link ( actor_ptr &  lhs,
actor_ptr &&  rhs 
)

Links lhs and rhs;.

Parameters:
lhsFirst Actor instance.
rhsSecond Actor instance.
Precondition:
lhs != rhs
Support for rvalue references.

void cppa::monitor ( actor_ptr &  whom)

Adds a monitor to whom.

Sends a ":Down" message to the calling Actor if whom exited.

Parameters:
whomActor 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.

Parameters:
whomActor instance that should be monitored by the calling Actor.
Support for rvalue references.

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.

Parameters:
whomReceiver of the message.
whatContent of the message.
Returns:
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.

Parameters:
whomActor that should be published at given port.
portUnused TCP port.
Exceptions:
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.

Parameters:
whomActor that should be published at given port.
portUnused TCP port.
Exceptions:
bind_failure
Support for rvalue references.

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.

Parameters:
reasonExit reason that will be send to linked actors.
Exceptions:
actor_exited

Alias for self()->quit(reason);

const any_tuple& cppa::receive ( )

Dequeues the next message from the mailbox.

Examples:
announce_example_2.cpp, and announce_example_3.cpp.
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); }

Parameters:
rulesInvoke 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); }

Parameters:
rulesInvoke rules to receive and handle messages.
Support for invoke rules with timeout.

void cppa::receive_loop ( invoke_rules &&  rules)

Receives messages in an endless loop.

Semantically equal to: for (;;) { receive(rules); }

Parameters:
rulesInvoke rules to receive and handle messages.
Support for rvalue references.

void cppa::receive_loop ( timed_invoke_rules &&  rules)

Receives messages in an endless loop.

Semantically equal to: for (;;) { receive(rules); }

Parameters:
rulesInvoke rules to receive and handle messages.
Support for rvalue references and timeout.

template<typename Head , typename... Tail>
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);
See also:
receive_loop(invoke_rules&)
template<typename Head , typename... Tail>
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);
See also:
receive_loop(invoke_rules&)

Support for rvalue references.

template<typename Statement >
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
 );
Parameters:
stmtLambda expression, functor or function returning a bool.
Returns:
A functor implementing the loop.
Examples:
announce_example_1.cpp, announce_example_4.cpp, and announce_example_5.cpp.
actor_ptr cppa::remote_actor ( const char *  host,
std::uint16_t  port 
)

Establish a new connection to the actor at host on given port.

Parameters:
hostValid hostname or IP address.
portTCP port.
Returns:
A pointer to the proxy instance that represents the remote Actor.
local_actor* cppa::self ( )

Get a pointer to the current active context.

Returns:
A pointer that identifies the calling actor.
template<typename Arg0 , typename... Args>
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.

Parameters:
whomReceiver of the message.
arg0First value for the message content.
argsAny number of values for the message content.
Examples:
announce_example_1.cpp, announce_example_2.cpp, announce_example_3.cpp, announce_example_4.cpp, and announce_example_5.cpp.
void cppa::set_scheduler ( scheduler *  sched)

Sets the scheduler to sched.

Parameters:
schedA user-defined scheduler implementation.
Precondition:
sched != nullptr.
Exceptions:
std::runtime_errorif there's already a scheduler defined.
template<scheduling_hint Hint, typename F , typename... Args>
actor_ptr cppa::spawn ( F &&  what,
const Args &...  args 
)

Spawns a new actor that executes what with given arguments.

Parameters:
HintHint to the scheduler for the best scheduling strategy.
whatFunction or functor that the spawned Actor should execute.
argsArguments needed to invoke what.
Returns:
A pointer to the newly created Actor.
template<typename F , typename... Args>
actor_ptr cppa::spawn ( F &&  what,
const Args &...  args 
)

Alias for spawn<scheduled>(what, args...).

Parameters:
whatFunction or functor that the spawned Actor should execute.
argsArguments needed to invoke what.
Returns:
A pointer to the newly created Actor.
template<typename T >
std::string cppa::to_string ( const T &  what)

Serializes a value to a string.

Parameters:
whatA value of an announced type.
Returns:
A string representation of 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.

Returns:
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.

Parameters:
new_valueSet 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.

Returns:
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.

Returns:
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;.