本文整理汇总了C++中HPX_THROWS_IF函数的典型用法代码示例。如果您正苦于以下问题:C++ HPX_THROWS_IF函数的具体用法?C++ HPX_THROWS_IF怎么用?C++ HPX_THROWS_IF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HPX_THROWS_IF函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: get_thread_priority
threads::thread_priority get_thread_priority(thread_id_type id, error_code& ec)
{
hpx::applier::applier* app = hpx::applier::get_applier_ptr();
if (NULL == app)
{
HPX_THROWS_IF(ec, invalid_status,
"hpx::threads::get_thread_priority",
"global applier object is not accessible");
return threads::thread_priority_unknown;
}
if (&ec != &throws)
ec = make_success_code();
return app->get_thread_manager().get_priority(id);
}
开发者ID:NOMORECOFFEE,项目名称:hpx,代码行数:16,代码来源:thread_helpers.cpp
示例2: set_thread_data
std::size_t set_thread_data(thread_id_type id, std::size_t d, error_code& ec)
{
hpx::applier::applier* app = hpx::applier::get_applier_ptr();
if (NULL == app)
{
HPX_THROWS_IF(ec, invalid_status,
"hpx::threads::set_thread_data",
"global applier object is not accessible");
return 0;
}
if (&ec != &throws)
ec = make_success_code();
return app->get_thread_manager().set_thread_data(id, d, ec);
}
开发者ID:NOMORECOFFEE,项目名称:hpx,代码行数:16,代码来源:thread_helpers.cpp
示例3: get_thread_backtrace
util::backtrace const* get_thread_backtrace(thread_id_type id, error_code& ec)
{
hpx::applier::applier* app = hpx::applier::get_applier_ptr();
if (NULL == app)
{
HPX_THROWS_IF(ec, invalid_status,
"hpx::threads::get_thread_backtrace",
"global applier object is not accessible");
return NULL;
}
if (&ec != &throws)
ec = make_success_code();
return app->get_thread_manager().get_backtrace(id);
}
开发者ID:khronos4,项目名称:hpx,代码行数:16,代码来源:thread_helpers.cpp
示例4: decode_compact_distribution
void decode_compact_distribution(hwloc_topology& t,
std::vector<mask_type>& affinities, error_code& ec)
{
std::size_t num_threads = affinities.size();
for(std::size_t i = 0; i != num_threads; ++i)
{
if (any(affinities[i]))
{
HPX_THROWS_IF(ec, bad_parameter, "decode_compact_distribution",
boost::str(boost::format("affinity mask for thread %1% has "
"already been set") % i));
return;
}
affinities[i] = t.init_thread_affinity_mask(i);
}
}
开发者ID:qiutaoleo,项目名称:hpx,代码行数:16,代码来源:parse_affinity_options.cpp
示例5: suspend
threads::thread_state_ex_enum suspend(
boost::posix_time::time_duration const& after_duration,
char const* description, error_code& ec)
{
// handle interruption, if needed
this_thread::interruption_point();
// schedule a thread waking us up after_duration
threads::thread_self& self = threads::get_self();
threads::thread_id_type id = self.get_thread_id();
threads::set_thread_state(id,
after_duration, threads::pending, threads::wait_signaled,
threads::thread_priority_critical, ec);
if (ec) return threads::wait_unknown;
// let the thread manager do other things while waiting
threads::thread_state_ex_enum statex = threads::wait_unknown;
{
// verify that there are no more registered locks for this OS-thread
util::verify_no_locks();
// suspend the HPX-thread
detail::reset_lco_description desc(id, description, ec);
#if HPX_THREAD_MAINTAIN_BACKTRACE_ON_SUSPENSION
detail::reset_backtrace bt(id, ec);
#endif
statex = self.yield(threads::suspended);
}
// handle interrupt and abort
this_thread::interruption_point();
if (statex == threads::wait_abort) {
hpx::util::osstream strm;
strm << "thread(" << id << ", "
<< threads::get_thread_description(id)
<< ") aborted (yield returned wait_abort)";
HPX_THROWS_IF(ec, yield_aborted, description,
hpx::util::osstream_get_string(strm));
}
if (&ec != &throws)
ec = make_success_code();
return statex;
}
开发者ID:khronos4,项目名称:hpx,代码行数:47,代码来源:thread_helpers.cpp
示例6: register_thread_plain
threads::thread_id_type register_thread_plain(
threads::thread_init_data& data, threads::thread_state_enum state,
bool run_now, error_code& ec)
{
hpx::applier::applier* app = hpx::applier::get_applier_ptr();
if (NULL == app)
{
HPX_THROWS_IF(ec, invalid_status,
"hpx::applier::register_thread_plain",
"global applier object is not accessible");
return threads::invalid_thread_id;
}
threads::thread_id_type id = threads::invalid_thread_id;
app->get_thread_manager().register_thread(data, id, state, run_now, ec);
return id;
}
开发者ID:gbibek,项目名称:hpx-1,代码行数:17,代码来源:applier.cpp
示例7: switch
parcelset::endpoints_type request::get_endpoints(
error_code& ec
) const
{ // {{{
switch (data->which())
{
case request_data::subtype_locality_count:
return data->get_data<request_data::subtype_locality_count, 0>(ec);
default: {
HPX_THROWS_IF(ec, bad_parameter,
"request::get_endpoints",
"invalid operation for request type");
return parcelset::endpoints_type();
}
}
} // }}}
开发者ID:HadrienG2,项目名称:hpx,代码行数:17,代码来源:request.cpp
示例8: set_thread_lco_description
char const* set_thread_lco_description(thread_id_type const& id,
char const* desc, error_code& ec)
{
hpx::applier::applier* app = hpx::applier::get_applier_ptr();
if (NULL == app)
{
HPX_THROWS_IF(ec, invalid_status,
"hpx::threads::set_thread_lco_description",
"global applier object is not accessible");
return NULL;
}
if (&ec != &throws)
ec = make_success_code();
return app->get_thread_manager().set_lco_description(id, desc);
}
开发者ID:DawidvC,项目名称:hpx,代码行数:17,代码来源:thread_helpers.cpp
示例9: l
// Stop the executor identified with the given cookie
void resource_manager::stop_executor(std::size_t cookie, error_code& ec)
{
std::lock_guard<mutex_type> l(mtx_);
proxies_map_type::iterator it = proxies_.find(cookie);
if (it == proxies_.end()) {
HPX_THROWS_IF(ec, bad_parameter, "resource_manager::detach",
"the given cookie is not known to the resource manager");
return;
}
// inform executor to give up virtual cores
proxy_data& p = (*it).second;
for (coreids_type coreids : p.core_ids_)
{
p.proxy_->remove_processing_unit(coreids.second, ec);
}
}
开发者ID:khuck,项目名称:hpx,代码行数:18,代码来源:resource_manager.cpp
示例10: suspend
/// The function \a suspend will return control to the thread manager
/// (suspends the current thread). It sets the new state of this thread
/// to the thread state passed as the parameter.
///
/// If the suspension was aborted, this function will throw a
/// \a yield_aborted exception.
threads::thread_state_ex_enum suspend(threads::thread_state_enum state,
char const* description, error_code& ec)
{
// handle interruption, if needed
this_thread::interruption_point();
// let the thread manager do other things while waiting
threads::thread_self& self = threads::get_self();
threads::thread_state_ex_enum statex = threads::wait_unknown;
{
// verify that there are no more registered locks for this OS-thread
#if HPX_HAVE_VERIFY_LOCKS
util::verify_no_locks();
#endif
#if HPX_THREAD_MAINTAIN_DESCRIPTION
threads::thread_id_type id = self.get_thread_id();
detail::reset_lco_description desc(id, description, ec);
#endif
#if HPX_THREAD_MAINTAIN_BACKTRACE_ON_SUSPENSION
detail::reset_backtrace bt(id, ec);
#endif
// suspend the HPX-thread
statex = self.yield(state);
}
// handle interruption, if needed
this_thread::interruption_point();
// handle interrupt and abort
if (statex == threads::wait_abort) {
threads::thread_id_type id = self.get_thread_id();
hpx::util::osstream strm;
strm << "thread(" << id << ", "
<< threads::get_thread_description(id)
<< ") aborted (yield returned wait_abort)";
HPX_THROWS_IF(ec, yield_aborted, description,
hpx::util::osstream_get_string(strm));
}
if (&ec != &throws)
ec = make_success_code();
return statex;
}
开发者ID:NOMORECOFFEE,项目名称:hpx,代码行数:51,代码来源:thread_helpers.cpp
示例11: hwloc_bitmap_alloc
void hwloc_topology::set_thread_affinity_mask(
mask_type mask
, error_code& ec
) const
{ // {{{
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
for (std::size_t i = 0; i < sizeof(std::size_t) * CHAR_BIT; ++i)
{
if (mask & (static_cast<std::size_t>(1) << i))
{
hwloc_bitmap_set(cpuset, static_cast<unsigned int>(i));
}
}
{
scoped_lock lk(topo_mtx);
if (hwloc_set_cpubind(topo, cpuset,
HWLOC_CPUBIND_STRICT | HWLOC_CPUBIND_THREAD))
{
// Strict binding not supported or failed, try weak binding.
if (hwloc_set_cpubind(topo, cpuset, HWLOC_CPUBIND_THREAD))
{
hwloc_bitmap_free(cpuset);
HPX_THROWS_IF(ec, kernel_error
, "hpx::threads::hwloc_topology::set_thread_affinity_mask"
, boost::str(boost::format(
"failed to set thread %x affinity mask")
% mask));
if (ec)
return;
}
}
}
#if defined(__linux) || defined(linux) || defined(__linux__) || defined(__FreeBSD__)
sleep(0); // Allow the OS to pick up the change.
#endif
hwloc_bitmap_free(cpuset);
if (&ec != &throws)
ec = make_success_code();
} // }}}
开发者ID:fpelliccioni,项目名称:hpx,代码行数:45,代码来源:hwloc_topology.cpp
示例12: set_thread_affinity_mask
void set_thread_affinity_mask(
boost::thread& thrd
, mask_type mask
, error_code& ec = throws
) const
{ // {{{
if (!SetThreadAffinityMask(thrd.native_handle(), DWORD_PTR(mask)))
{
HPX_THROWS_IF(ec, kernel_error
, "hpx::threads::windows_topology::set_thread_affinity_mask"
, boost::str(boost::format(
"failed to set thread %1% affinity mask")
% mask));
}
else if (&ec != &throws)
ec = make_success_code();
} // }}}
开发者ID:fpelliccioni,项目名称:hpx,代码行数:18,代码来源:windows_topology.hpp
示例13: set_thread_state
thread_state set_thread_state(thread_id_type id, thread_state_enum state,
thread_state_ex_enum stateex, thread_priority priority, error_code& ec)
{
hpx::applier::applier* app = hpx::applier::get_applier_ptr();
if (NULL == app)
{
HPX_THROWS_IF(ec, invalid_status,
"hpx::threads::set_thread_state",
"global applier object is not accessible");
return thread_state(unknown);
}
if (&ec != &throws)
ec = make_success_code();
return app->get_thread_manager().set_state(id, state, stateex,
priority, ec);
}
开发者ID:NOMORECOFFEE,项目名称:hpx,代码行数:18,代码来源:thread_helpers.cpp
示例14: switch
// Return the requested policy element
std::size_t generic_thread_pool_executor::get_policy_element(
threads::detail::executor_parameter p, error_code& ec) const
{
switch(p) {
case threads::detail::min_concurrency:
case threads::detail::max_concurrency:
case threads::detail::current_concurrency:
return hpx::get_os_thread_count();
default:
break;
}
HPX_THROWS_IF(ec, bad_parameter,
"thread_pool_executor::get_policy_element",
"requested value of invalid policy element");
return std::size_t(-1);
}
开发者ID:DawidvC,项目名称:hpx,代码行数:19,代码来源:generic_thread_pool_executor.cpp
示例15: get_next_id
naming::gid_type get_next_id(
std::size_t count
, error_code& ec
)
{
if (get_runtime_ptr() == 0)
{
HPX_THROWS_IF(ec, invalid_status,
"get_next_id", "the runtime system has not been started yet.");
return naming::invalid_gid;
}
naming::resolver_client& agas_ = naming::get_agas_client();
naming::gid_type lower_bound, upper_bound;
agas_.get_id_range(count, lower_bound, upper_bound, ec);
if (ec) return naming::invalid_gid;
return lower_bound;
}
开发者ID:AntonBikineev,项目名称:hpx,代码行数:19,代码来源:interface.cpp
示例16: set_thread_state
thread_id_type set_thread_state(thread_id_type const& id,
boost::posix_time::time_duration const& after, thread_state_enum state,
thread_state_ex_enum stateex, thread_priority priority, error_code& ec)
{
hpx::applier::applier* app = hpx::applier::get_applier_ptr();
if (NULL == app)
{
HPX_THROWS_IF(ec, invalid_status,
"hpx::threads::set_thread_state",
"global applier object is not accessible");
return invalid_thread_id;
}
if (&ec != &throws)
ec = make_success_code();
return app->get_thread_manager().set_state(after, id, state,
stateex, priority, ec);
}
开发者ID:DawidvC,项目名称:hpx,代码行数:19,代码来源:thread_helpers.cpp
示例17: l
response component_namespace::bind_name(
request const& req
, error_code& ec
)
{ // {{{ bind_name implementation
// parameters
std::string key = req.get_name();
std::unique_lock<mutex_type> l(mutex_);
component_id_table_type::left_map::iterator it = component_ids_.left.find(key)
, end = component_ids_.left.end();
// If the name is not in the table, register it (this is only done so
// we can implement a backwards compatible get_component_id).
if (it == end)
{
if (HPX_UNLIKELY(!util::insert_checked(component_ids_.left.insert(
std::make_pair(key, type_counter)), it)))
{
l.unlock();
HPX_THROWS_IF(ec, lock_error
, "component_namespace::bind_name"
, "component id table insertion failed due to a locking "
"error or memory corruption");
return response();
}
// If the insertion succeeded, we need to increment the type
// counter.
++type_counter;
}
LAGAS_(info) << (boost::format(
"component_namespace::bind_name, key(%1%), ctype(%2%)")
% key % it->second);
if (&ec != &throws)
ec = make_success_code();
return response(component_ns_bind_name, it->second);
} // }}}
开发者ID:jyzhang-bjtu,项目名称:hpx,代码行数:43,代码来源:component_namespace_server.cpp
示例18: decode_balanced_distribution
void decode_balanced_distribution(hwloc_topology& t,
std::vector<mask_type>& affinities,
std::size_t used_cores, std::size_t max_cores,
std::vector<std::size_t>& num_pus, error_code& ec)
{
std::size_t num_threads = affinities.size();
std::size_t num_cores = (std::min)(max_cores, t.get_number_of_cores());
std::vector<std::size_t> num_pus_cores(num_cores, 0);
num_pus.resize(num_threads);
// At first, calculate the number of used pus per core.
// This needs to be done to make sure that we occupy all the available cores
for (std::size_t num_thread = 0; num_thread != num_threads; /**/)
{
for(std::size_t num_core = 0; num_core != num_cores; ++num_core)
{
num_pus_cores[num_core]++;
if(++num_thread == num_threads)
break;
}
}
// Iterate over the cores and assigned pus per core. this additional loop
// is needed so that we have consecutive worker thread numbers
std::size_t num_thread = 0;
for(std::size_t num_core = 0; num_core != num_cores; ++num_core)
{
for(std::size_t num_pu = 0; num_pu != num_pus_cores[num_core]; ++num_pu)
{
if (any(affinities[num_thread]))
{
HPX_THROWS_IF(ec, bad_parameter, "decode_balanced_distribution",
boost::str(boost::format("affinity mask for thread %1% has "
"already been set") % num_thread));
return;
}
num_pus[num_thread] = t.get_pu_number(num_core + used_cores, num_pu);
affinities[num_thread] = t.init_thread_affinity_mask(
num_core + used_cores, num_pu);
++num_thread;
}
}
}
开发者ID:HadrienG2,项目名称:hpx,代码行数:43,代码来源:parse_affinity_options.cpp
示例19: get_numa_node_number
std::size_t get_numa_node_number(
std::size_t num_thread
, error_code& ec = throws
) const
{ // {{{
if (num_thread < numa_node_numbers_.size())
{
if (&ec != &throws)
ec = make_success_code();
return numa_node_numbers_[num_thread];
}
HPX_THROWS_IF(ec, bad_parameter
, "hpx::threads::windows_topology::get_numa_node_number"
, boost::str(boost::format(
"thread number %1% is out of range")
% num_thread));
return std::size_t(-1);
} // }}}
开发者ID:fpelliccioni,项目名称:hpx,代码行数:20,代码来源:windows_topology.hpp
示例20: regex_from_pattern
std::string regex_from_pattern(std::string const& pattern, error_code& ec)
{
std::string result;
std::string::const_iterator end = pattern.end();
for (std::string::const_iterator it = pattern.begin(); it != end; ++it)
{
char c = *it;
switch (c) {
case '*':
result.append(".*");
break;
case '?':
result.append(1, '.');
break;
case '[':
{
std::string r = regex_from_character_set(it, end, ec);
if (ec) return "";
result.append(r);
}
break;
case '\\':
if (++it == end) {
HPX_THROWS_IF(ec, bad_parameter,
"regex_from_pattern",
"Invalid escape sequence at: " + pattern);
return "";
}
result.append(1, *it);
break;
default:
result.append(1, c);
break;
}
}
return result;
}
开发者ID:brycelelbach,项目名称:hpx,代码行数:41,代码来源:registry.cpp
注:本文中的HPX_THROWS_IF函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论