mutex::~mutex() { HPX_ITT_SYNC_DESTROY(this); if (!queue_.empty()) { LERR_(fatal) << "lcos::local::mutex::~mutex: " << description_ << ": queue is not empty"; mutex_type::scoped_lock l(mtx_); while (!queue_.empty()) { threads::thread_id_type id = queue_.front().id_; queue_.front().id_ = 0; queue_.pop_front(); // we know that the id is actually the pointer to the thread LERR_(fatal) << "lcos::local::mutex::~mutex: " << description_ << ": pending thread: " << threads::get_thread_state_name(threads::get_thread_state(id)) << "(" << id << "): " << threads::get_thread_description(id); // forcefully abort thread, do not throw error_code ec(lightweight); threads::set_thread_state(id, threads::pending, threads::wait_abort, threads::thread_priority_default, ec); if (ec) { LERR_(fatal) << "lcos::local::mutex::~mutex: could not abort thread" << get_thread_state_name(threads::get_thread_state(id)) << "(" << id << "): " << threads::get_thread_state(id); } } } }
void log_non_empty_queue(char const* const desc, queue_type& queue) { mutex_type::scoped_lock l(mtx_); while (!queue.empty()) { threads::thread_id_type id = queue.front().id_; queue.front().id_ = 0; queue.pop_front(); // we know that the id is actually the pointer to the thread threads::thread_data* thrd = reinterpret_cast<threads::thread_data*>(id); LERR_(info) << "~full_empty_entry: aborting pending thread in " << desc << ": " << get_thread_state_name(thrd->get_state()) << "(" << id << "): " << thrd->get_description(); // forcefully abort thread, do not throw error_code ec(lightweight); threads::set_thread_state(id, threads::pending, threads::wait_abort, threads::thread_priority_normal, ec); if (ec) { LERR_(error) << "~full_empty_entry: could not abort thread" << get_thread_state_name(thrd->get_state()) << "(" << id << "): " << thrd->get_description(); } } }
/** try to parse a time specification in seconds or fractional seconds. * The value is interpreted relative to the origin of a the given time grid * This parser recognises full seconds, fractional seconds and both together. * In any case, the actual number is required to end with a trailing \c 'sec' * @par Example specifications \verbatim 12sec --> 12 * TimeValue::SCALE -4sec --> -4 * TimeValue::SCALE 5/4sec --> 1.25 * TimeValue::SCALE -5/25sec --> -0.2 * TimeValue::SCALE 1+1/2sec --> 1.5 * TimeValue::SCALE 1-1/25sec --> 0.96 * TimeValue::SCALE -12-1/4sec --> -11.75 * TimeValue::SCALE \endverbatim * @param seconds string containing a time spec in seconds * @param grid coordinate system the parsed value is based on * @return the corresponding (opaque internal) lumiera time value * @throw error::Invalid in case of parsing failure * @note the string may contain any additional content, as long as a * regular-expression search is able to pick out a suitable value */ TimeValue Seconds::parse (string const& seconds, QuantR grid) { static regex fracSecs_parser ("(?<![\\./\\-\\d])(-?\\d+)(?:([\\-\\+]\\d+)?/(\\d+))?sec"); //__no leading[./-\d] number [+-] number '/' number 'sec' #define SUB_EXPR(N) lexical_cast<long> (match[N]) smatch match; if (regex_search (seconds, match, fracSecs_parser)) if (match[2].matched) { // complete spec with all parts FSecs fractionalPart (SUB_EXPR(2), SUB_EXPR(3)); long fullSeconds (SUB_EXPR(1)); return grid.timeOf (fullSeconds + fractionalPart); } else if (match[3].matched) { // only a fractional part was given return grid.timeOf (FSecs (SUB_EXPR(1), SUB_EXPR(3))); } else { // just simple non-fractional seconds return grid.timeOf (FSecs (SUB_EXPR(1))); } else throw error::Invalid ("unable to parse \""+seconds+"\" as (fractional)seconds" , LERR_(INVALID_TIMECODE)); }
static PlacementMX& access (_Id const& placementID) { if (!placementID) throw error::Logic ("Attempt to access a NIL PlacementRef" , LERR_(BOTTOM_PLACEMENTREF)); Placement<MObject> & genericPlacement (session::SessionServiceFetch::resolveID (placementID)); // may throw REQUIRE (genericPlacement.isValid()); if (!(genericPlacement.template isCompatible<MX>())) throw error::Invalid("actual type of the resolved placement is incompatible" , LERR_(INVALID_PLACEMENTREF)); ////////////////////////TODO: 1. better message, including type? ////////////////////////TODO: 2. define a separate error-ID for the type mismatch! return static_cast<PlacementMX&> (genericPlacement); }
/** try to parse a frame number specification * @param frameNumber string containing an integral number with trailing '#' * @param frameGrid coordinate system (and thus framerate) to use for the conversion * @return (opaque internal) lumiera time value of the given frame's start position * @throw error::Invalid in case of parsing failure * @note the string may contain any additional content, as long as a * regular-expression search is able to pick out a suitable value */ TimeValue Frames::parse (string const& frameNumber, QuantR frameGrid) { static regex frameNr_parser ("(?<![\\.\\-\\d])(-?\\d+)#"); // no leading [.-\d], number+'#' smatch match; if (regex_search (frameNumber, match, frameNr_parser)) return frameGrid.timeOf (lexical_cast<FrameCnt> (match[1])); else throw error::Invalid ("unable to parse framecount \""+frameNumber+"\"" , LERR_(INVALID_TIMECODE)); }
~counting_semaphore() { typename mutex_type::scoped_lock l(mtx_); if (!queue_.empty()) { LERR_(fatal) << "lcos::counting_semaphore::~counting_semaphore:" " queue is not empty, aborting threads"; while (!queue_.empty()) { threads::thread_id_type id = queue_.front().id_; queue_.front().id_ = 0; queue_.pop_front(); // we know that the id is actually the pointer to the thread LERR_(fatal) << "lcos::counting_semaphore::~counting_semaphore:" << " pending thread: " << get_thread_state_name(threads::get_thread_state(id)) << "(" << id << "): " << threads::get_thread_description(id); // forcefully abort thread, do not throw error_code ec(lightweight); threads::set_thread_state(id, threads::pending, threads::wait_abort, threads::thread_priority_default, ec); if (ec) { LERR_(fatal) << "lcos::counting_semaphore::~counting_semaphore:" << " could not abort thread: " << get_thread_state_name(threads::get_thread_state(id)) << "(" << id << "): " << threads::get_thread_description(id); } } } }
// verify that no locks are held by this HPX-thread void verify_no_locks() { if (register_locks::lock_detection_enabled_ && 0 != threads::get_self_ptr()) { register_locks::held_locks_map const& held_locks = register_locks::get_lock_map(); // we create a log message if there are still registered locks for // this OS-thread if (!held_locks.empty()) { std::string back_trace(hpx::detail::backtrace_direct()); if (back_trace.empty()) { LERR_(debug) << "suspending thread while at least one lock is being held " "(stack backtrace was disabled at compile time)"; } else { LERR_(debug) << "suspending thread while at least one lock is being held, " << "stack backtrace: " << back_trace; } } } }
/** Access to the "current session", which actually is * an SessionImpl instance. This session object is created * either by loading an existing session, or on demand by * this accessor function here (when no session was loaded * or created) * @note any exceptions arising while building the basic * session object(s) will halt the system. */ SessionImplAPI* SessManagerImpl::operator-> () noexcept { if (!pSess_) try { // create empty default configured session this->reset(); } catch (...) { ERROR (progress, "Unrecoverable Failure while creating the empty default session."); throw lumiera::error::Fatal ( "Failure while creating the basic session object. System halted." , LERR_(CREATE_SESSION)); } return pSess_.get(); }
/// Construct a hpx::exception from a \a hpx::error and an error message. /// /// \param e The parameter \p e holds the hpx::error code the new /// exception should encapsulate. /// \param msg The parameter \p msg holds the error message the new /// exception should encapsulate. /// \param mode The parameter \p mode specifies whether the returned /// hpx::error_code belongs to the error category /// \a hpx_category (if mode is \a plain, this is the /// default) or to the category \a hpx_category_rethrow /// (if mode is \a rethrow). exception::exception(error e, char const* msg, throwmode mode) : boost::system::system_error(make_system_error_code(e, mode), msg) { HPX_ASSERT((e >= success && e < last_error) || (e & system_error_flag)); LERR_(error) << "created exception: " << this->what(); }
/// Construct a hpx::exception from a boost#system_error. exception::exception(boost::system::system_error const& e) : boost::system::system_error(e) { LERR_(error) << "created exception: " << this->what(); }
/////////////////////////////////////////////////////////////////////////// /// Construct a hpx::exception from a \a hpx::error. /// /// \param e The parameter \p e holds the hpx::error code the new /// exception should encapsulate. exception::exception(error e) : boost::system::system_error(make_error_code(e, plain)) { HPX_ASSERT((e >= success && e < last_error) || (e & system_error_flag)); LERR_(error) << "created exception: " << this->what(); }