本文整理汇总了C++中actor类的典型用法代码示例。如果您正苦于以下问题:C++ actor类的具体用法?C++ actor怎么用?C++ actor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了actor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: spawn
inline void spawn(
spawn_type spw,
actor<stackless>& sire, match_t func, SpawnHandler h,
match_t ctxid = ctxid_nil,
link_type type = no_link,
std::size_t stack_size = default_stacksize(),
seconds_t tmo = seconds_t(GCE_DEFAULT_REQUEST_TIMEOUT_SEC)
)
{
aid_t aid;
sid_t sid = sire.spawn(spw, func, ctxid, stack_size);
boost::uint16_t err = 0;
sid_t ret_sid = sid_nil;
duration_t curr_tmo = tmo;
typedef boost::chrono::system_clock clock_t;
clock_t::time_point begin_tp = clock_t::now();
match mach(curr_tmo);
mach.match_list_.push_back(detail::msg_spawn_ret);
sire.recv(
boost::bind(
&handle_remote_spawn, _1, _2, _3,
type, begin_tp, sid, tmo, curr_tmo, spawn_handler_t(h)
),
mach
);
}
开发者ID:zhangf911,项目名称:GCEDemo,代码行数:27,代码来源:spawn.hpp
示例2: spawn
actor_id spawn(actor sire, F&& f, fiber_meta meta)
{
// Create actor handler.
actor_handler_t hdr(f);
// Generate actor_id.
auto aid = generate_actor_id();
// Spawn an coctx.
asev::strand_t snd(*evs_);
auto sire_aid = sire == nullactor ? nullaid : sire.get_actor_id();
if (sire_aid != nullaid && meta.ssire_)
{
snd = sire.get_strand();
}
snd.spawn(
[this, sire_aid, hdr, aid](asev::corctx_t& ctx)
{
// Alloc fiber_actor.
auto a = fiber_actor_pool_->get();
// Run actor.
a->init(aid, ctx.get_strand());
a->run(ctx, sire_aid, std::move(hdr));
},
coctx::make_stacksize(meta.ssize_)
);
return aid;
}
开发者ID:nousxiong,项目名称:actorx,代码行数:29,代码来源:ax_service.hpp
示例3: handle_remote_spawn
inline void handle_remote_spawn(
actor<stackless>& self, aid_t aid,
message msg, link_type type,
boost::chrono::system_clock::time_point begin_tp,
sid_t sid, seconds_t tmo, duration_t curr_tmo,
spawn_handler_t const& hdr
)
{
boost::uint16_t err = 0;
sid_t ret_sid = sid_nil;
msg >> err >> ret_sid;
do
{
if (err != 0 || (aid && sid == ret_sid))
{
break;
}
if (tmo != infin)
{
duration_t pass_time = boost::chrono::system_clock::now() - begin_tp;
curr_tmo -= pass_time;
}
begin_tp = boost::chrono::system_clock::now();
match mach(curr_tmo);
mach.match_list_.push_back(detail::msg_spawn_ret);
self.recv(
boost::bind(
&handle_remote_spawn, _1, _2, _3,
type, begin_tp, sid, tmo, curr_tmo, hdr
),
mach
);
return;
}
while (false);
detail::spawn_error error = (detail::spawn_error)err;
if (error != detail::spawn_ok)
{
aid = aid_t();
}
if (aid)
{
if (type == linked)
{
self.link(aid);
}
else if (type == monitored)
{
self.monitor(aid);
}
}
hdr(self, aid);
}
开发者ID:zhangf911,项目名称:GCEDemo,代码行数:59,代码来源:spawn.hpp
示例4:
bool manager::actualize_doors_state ( actor& actor, float const average_speed )
{
float const radius = average_speed*g_door_open_time + g_door_length;
Fvector const& position = actor.get_position();
//check_bug_door ( );
m_doors.nearest ( position, radius, m_nearest_doors );
//check_bug_door ( );
if ( m_nearest_doors.empty() && !actor.need_update() )
return true;
return actor.update_doors( m_nearest_doors, average_speed );
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:12,代码来源:doors_manager.cpp
示例5:
actor operator*(actor f, actor g) {
auto& sys = f->home_system();
return make_actor<decorator::sequencer, actor>(
sys.next_actor_id(), sys.node(), &sys,
actor_cast<strong_actor_ptr>(std::move(f)),
actor_cast<strong_actor_ptr>(std::move(g)), std::set<std::string>{});
}
开发者ID:alexeiz,项目名称:actor-framework,代码行数:7,代码来源:actor.cpp
示例6: send_message
void send_message(actor& source, actor& target, const std::string& message)
{
ac_message_t msg;
msg.src = &source;
msg.message = message;
target.enqueue(msg);
}
开发者ID:promise6522,项目名称:test,代码行数:7,代码来源:coroutine.cpp
示例7: animateActor
void renderer::animateActor(actor &character, bool isMoving)
{
double temp[2];
(character.animationStep > 6) ? character.animationStep = 0 : 0;
switch(character.face)
{
case Up:
case UpRight:
case UpLeft:
temp[1] = .25;
break;
case Left: temp[1] = 0;
break;
case Down:
case DownRight:
case DownLeft: temp[1] = .75;
break;
case Right: temp[1] = .5;
break;
default:
break;
}
temp[0] = double(character.animationStep)*.125;
character.animationStep++;
characterData[character.getID()].moveActorCoords(temp);
}
开发者ID:cwillison94,项目名称:CurrentVersion,代码行数:27,代码来源:RENDERER.cpp
示例8: put_named
void actor_registry::put_named(atom_value key, actor value) {
if (value)
value->attach_functor([=](uint32_t) {
detail::singletons::get_actor_registry()->put_named(key, invalid_actor);
});
exclusive_guard guard{named_entries_mtx_};
named_entries_.emplace(key, std::move(value));
}
开发者ID:Neverlord,项目名称:boost.actor,代码行数:8,代码来源:actor_registry.cpp
示例9: sync_send_tuple_impl
message_id local_actor::sync_send_tuple_impl(message_priority mp,
const actor& dest,
any_tuple&& what) {
auto nri = new_request_id();
if (mp == message_priority::high) nri = nri.with_high_priority();
dest->enqueue({address(), dest, nri}, std::move(what));
return nri.response_id();
}
开发者ID:ajac,项目名称:libcppa,代码行数:8,代码来源:local_actor.cpp
示例10: send_as
void send_as(const actor& from, message_priority prio,
const channel& to, Ts&&... xs) {
if (! to) {
return;
}
message_id mid;
to->enqueue(from.address(),
prio == message_priority::high ? mid.with_high_priority() : mid,
make_message(std::forward<Ts>(xs)...), nullptr);
}
开发者ID:Neverlord,项目名称:boost.actor,代码行数:10,代码来源:send.hpp
示例11: handle_spawn
inline void handle_spawn(
actor<stackless>& self, aid_t aid,
message msg, link_type type, spawn_handler_t const& hdr
)
{
if (aid)
{
if (type == linked)
{
self.link(aid);
}
else if (type == monitored)
{
self.monitor(aid);
}
}
hdr(self, aid);
}
开发者ID:zhangf911,项目名称:GCEDemo,代码行数:19,代码来源:spawn.hpp
示例12: delegate
void delegate(message_priority mp, const actor& dest, Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "no message to send");
if (! dest)
return;
auto mid = current_element_->mid;
current_element_->mid = mp == message_priority::high
? mid.with_high_priority()
: mid.with_normal_priority();
current_element_->msg = make_message(std::forward<Ts>(xs)...);
dest->enqueue(std::move(current_element_), host());
}
开发者ID:guigra,项目名称:actor-framework,代码行数:11,代码来源:local_actor.hpp
示例13: forward_message
void local_actor::forward_message(const actor& dest, message_priority prio) {
if (!dest) {
return;
}
auto id = (prio == message_priority::high)
? m_current_node->mid.with_high_priority()
: m_current_node->mid.with_normal_priority();
dest->enqueue(m_current_node->sender, id, m_current_node->msg, host());
// treat this message as asynchronous message from now on
m_current_node->mid = invalid_message_id;
}
开发者ID:ariosx,项目名称:actor-framework,代码行数:11,代码来源:local_actor.cpp
示例14: sync_send_tuple_impl
message_id local_actor::sync_send_tuple_impl(message_priority mp,
const actor& dest,
any_tuple&& what) {
if (!dest) {
throw std::invalid_argument("cannot send synchronous message "
"to invalid_actor");
}
auto nri = new_request_id();
if (mp == message_priority::high) nri = nri.with_high_priority();
dest->enqueue({address(), dest, nri}, std::move(what), m_host);
return nri.response_id();
}
开发者ID:ras0219,项目名称:libcppa,代码行数:12,代码来源:local_actor.cpp
示例15: timed_sync_send_tuple_impl
message_id local_actor::timed_sync_send_tuple_impl(message_priority mp,
const actor& dest,
const util::duration& rtime,
any_tuple&& what) {
auto nri = new_request_id();
if (mp == message_priority::high) nri = nri.with_high_priority();
dest->enqueue({address(), dest, nri}, std::move(what));
auto rri = nri.response_id();
get_scheduler()->delayed_send({address(), this, rri}, rtime,
make_any_tuple(sync_timeout_msg{}));
return rri;
}
开发者ID:ajac,项目名称:libcppa,代码行数:12,代码来源:local_actor.cpp
示例16: echo
static void echo(actor<stackful>& self)
{
try
{
while (true)
{
message msg;
aid_t sender = self.recv(msg);
match_t type = msg.get_type();
if (type == atom("echo"))
{
self.send(sender, msg);
}
else
{
break;
}
}
}
catch (std::exception& ex)
{
std::cerr << "echo except: " << ex.what() << std::endl;
}
}
开发者ID:HappySky2046,项目名称:gce,代码行数:24,代码来源:test_socket.hpp
示例17: timed_sync_send_tuple_impl
message_id local_actor::timed_sync_send_tuple_impl(message_priority mp,
const actor& dest,
const util::duration& rtime,
any_tuple&& what) {
if (!dest) {
throw std::invalid_argument("cannot send synchronous message "
"to invalid_actor");
}
auto nri = new_request_id();
if (mp == message_priority::high) nri = nri.with_high_priority();
dest->enqueue({address(), dest, nri}, std::move(what), m_host);
auto rri = nri.response_id();
get_scheduling_coordinator()->delayed_send({address(), this, rri}, rtime,
make_any_tuple(sync_timeout_msg{}));
return rri;
}
开发者ID:ras0219,项目名称:libcppa,代码行数:16,代码来源:local_actor.cpp
示例18: timed_sync_send_tuple_impl
message_id local_actor::timed_sync_send_tuple_impl(message_priority mp,
const actor& dest,
const duration& rtime,
message&& what) {
if (!dest) {
throw std::invalid_argument(
"cannot send synchronous message "
"to invalid_actor");
}
auto nri = new_request_id();
if (mp == message_priority::high) {
nri = nri.with_high_priority();
}
dest->enqueue(address(), nri, std::move(what), host());
auto rri = nri.response_id();
auto sched_cd = detail::singletons::get_scheduling_coordinator();
sched_cd->delayed_send(rtime, address(), this, rri,
make_message(sync_timeout_msg{}));
return rri;
}
开发者ID:ariosx,项目名称:actor-framework,代码行数:20,代码来源:local_actor.cpp
示例19: demonitor
/// Removes a monitor from `whom`.
inline void demonitor(const actor& whom) {
demonitor(whom.address());
}
开发者ID:guigra,项目名称:actor-framework,代码行数:4,代码来源:local_actor.hpp
示例20: send_exit
/**
* Sends an exit message to `whom`.
*/
inline void send_exit(const actor& whom, uint32_t reason) {
send_exit(whom.address(), reason);
}
开发者ID:chen--oRanGe,项目名称:actor-framework,代码行数:6,代码来源:local_actor.hpp
注:本文中的actor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论