本文整理汇总了C++中request::get_on_event_event方法的典型用法代码示例。如果您正苦于以下问题:C++ request::get_on_event_event方法的具体用法?C++ request::get_on_event_event怎么用?C++ request::get_on_event_event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类request
的用法示例。
在下文中一共展示了request::get_on_event_event方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_event
response symbol_namespace::on_event(
request const& req
, error_code& ec
)
{ // {{{ on_event implementation
std::string name = req.get_name();
namespace_action_code evt = req.get_on_event_event();
bool call_for_past_events = req.get_on_event_call_for_past_event();
hpx::id_type lco = req.get_on_event_result_lco();
if (evt != symbol_ns_bind)
{
HPX_THROWS_IF(ec, bad_parameter,
"addressing_service::on_symbol_namespace_event",
"invalid event type");
return response(symbol_ns_on_event, no_success);
}
std::unique_lock<mutex_type> l(mutex_);
bool handled = false;
if (call_for_past_events)
{
gid_table_type::iterator it = gids_.find(name);
if (it != gids_.end())
{
// hold on to entry while map is unlocked
std::shared_ptr<naming::gid_type> current_gid(it->second);
// split the credit as the receiving end will expect to keep the
// object alive
{
util::unlock_guard<std::unique_lock<mutex_type> > ul(l);
naming::gid_type new_gid = naming::detail::split_gid_if_needed(
*current_gid).get();
// trigger the lco
handled = true;
// trigger LCO as name is already bound to an id
set_lco_value(lco, std::move(new_gid));
}
}
}
if (!handled)
{
std::pair<std::string, namespace_action_code> key(name, evt);
on_event_data_map_type::iterator it = on_event_data_.insert(
on_event_data_map_type::value_type(std::move(key), lco));
l.unlock();
if (it == on_event_data_.end())
{
LAGAS_(info) << (boost::format(
"symbol_namespace::on_event, name(%1%), response(no_success)")
% name);
if (&ec != &throws)
ec = make_success_code();
return response(symbol_ns_on_event, no_success);
}
}
else
{
l.unlock();
}
LAGAS_(info) << "symbol_namespace::on_event";
if (&ec != &throws)
ec = make_success_code();
return response(symbol_ns_on_event);
} // }}}