Ejemplo n.º 1
0
    statistics_counter<Statistic>::statistics_counter(
            counter_info const& info, std::string const& base_counter_name,
            boost::uint64_t parameter1, boost::uint64_t parameter2)
      : base_type_holder(info),
        timer_(util::bind(&statistics_counter::evaluate, this_()),
            util::bind(&statistics_counter::on_terminate, this_()),
            1000 * parameter1, info.fullname_, true),
        base_counter_name_(ensure_counter_prefix(base_counter_name)),
        value_(new detail::counter_type_from_statistic<Statistic>(parameter2)),
        parameter1_(parameter1), parameter2_(parameter2)
    {
        if (parameter1 == 0) {
            HPX_THROW_EXCEPTION(bad_parameter,
                "statistics_counter<Statistic>::statistics_counter",
                "base interval is specified to be zero");
        }

        if (info.type_ != counter_aggregating) {
            HPX_THROW_EXCEPTION(bad_parameter,
                "statistics_counter<Statistic>::statistics_counter",
                "unexpected counter type specified");
        }

        // make sure this counter starts collecting data
        start();
    }
Ejemplo n.º 2
0
 coalescing_message_handler::coalescing_message_handler(
         char const* action_name, parcelset::parcelport* pp, std::size_t num,
         std::size_t interval)
   : pp_(pp), buffer_(detail::get_num_messages(num)),
     timer_(boost::bind(&coalescing_message_handler::timer_flush, this_()),
         boost::bind(&coalescing_message_handler::flush, this_(), true),
         detail::get_interval(interval), std::string(action_name) + "_timer",
         true),
     stopped_(false)
 {}
Ejemplo n.º 3
0
    hpx::future<void> barrier_node::wait(bool async)
    {
        if (num_ < cut_off_)
        {
            if (rank_ != 0)
            {
                HPX_ASSERT(children_.size() == 1);
                hpx::lcos::base_lco::set_event_action action;
                return hpx::async(action, children_[0]);
            }
            else
            {
                if (async)
                {
                    boost::intrusive_ptr<barrier_node> this_(this);
                    return hpx::async(&barrier_node::set_event, this_);
                }
                set_event();
                return hpx::make_ready_future();
            }
        }

        future<void> result;

        if (rank_ == 0)
        {
            // The root process calls the gather action on its children
            // once all those return, we know that everyone entered the
            // barrier
            std::vector<hpx::future<void> > futures;
            futures.reserve(children_.size());
            for(hpx::id_type& id : children_)
            {
                barrier_node::gather_action action;
                futures.push_back(hpx::async(action, id));
            }
            result = hpx::when_all(futures);
        }
        else
        {
            // Non-root flags that it entered the barrier...
            gather_promise_.set_value();

            // The broadcast_promise is set once the root knows that everyone
            // entered the barrier
            result = broadcast_promise_.get_future();
        }

        if (async)
        {
            boost::intrusive_ptr<barrier_node> this_(this);
            return do_wait(this_, std::move(result));
        }
        return do_wait(this, std::move(result));
    }
Ejemplo n.º 4
0
void task::enqueue(task_worker_pool* pool)
{
    if (spec().type == TASK_TYPE_COMPUTE)
    {
        spec().on_task_enqueue.execute(task::get_current_task(), this);
    }

    // fast execution
    if (_delay_milliseconds == 0
        && (_spec->allow_inline || _spec->fast_execution_in_network_thread || _is_null)
       )
    {
        exec_internal();
    }

    // normal path
    else
    {
        dassert(pool != nullptr, "pool not exist, "
            "must be the case where the caller is executed in io threads "
            "which is forbidden unless you explicitly set [task.%s].fast_execution_in_network_thread = true",
            _spec->name
            );

        task_ptr this_(this);
        pool->enqueue(this_);
    }
}
Ejemplo n.º 5
0
            BOOST_FORCEINLINE
            void await_next(Iter iter, boost::mpl::true_, boost::mpl::false_)
            {
                typedef
                    typename boost::fusion::result_of::next<Iter>::type
                    next_type;

                typedef
                    typename util::decay_unwrap<
                        typename boost::fusion::result_of::deref<Iter>::type
                    >::type
                    future_type;
                future_type &  f_ =
                    boost::fusion::deref(iter);

                typedef
                    typename traits::future_traits<
                        future_type
                    >::type
                    future_result_type;

                boost::intrusive_ptr<
                    lcos::detail::future_data<future_result_type>
                > next_future_data
                    = traits::detail::get_shared_state(f_);

                if(!next_future_data->is_ready())
                {
                    next_future_data->execute_deferred();

                    // execute_deferred might have made the future ready
                    if (!next_future_data->is_ready())
                    {
                        void (dataflow_frame::*f)(
                                Iter, boost::mpl::true_, boost::mpl::false_
                            ) = &dataflow_frame::await_next_respawn;

                        boost::intrusive_ptr<dataflow_frame> this_(this);
                        next_future_data->set_on_completed(
                            hpx::util::bind(
                                f
                              , std::move(this_)
                              , std::move(iter)
                              , boost::mpl::true_()
                              , boost::mpl::false_()
                            )
                        );
                        return;
                    }
                }

                do_await(
                    policy_
                  , boost::fusion::next(iter)
                  , boost::mpl::bool_<
                        boost::is_same<next_type, end_type>::value
                    >()
                );
            }
Ejemplo n.º 6
0
 void swap(basic_message & other)
 {
     base_type & this_(*this);
     this_.swap(other);
     std::swap(other.version_, version_);
     std::swap(other.status_code_, status_code_);
     std::swap(other.status_msg_, status_msg_);
 }
Ejemplo n.º 7
0
const struct I2C* this_(constructor)(
		char slewRateControll,
		char inputThreshold,
		unsigned int clockPeriod,
		uint16_t slaveAddress,
		char generalCallInterrupt,
		char conditionInterrupt,
		char sdaHoldTime) {
	SSP1STATbits.SMP = slewRateControll;
	SSP1STATbits.CKE = inputThreshold;
	
	this_(slaveAddress) = slaveAddress;
	this_(sspm_slave) = this_(slaveAddress) > 0x7F ? 0b0111 : 0b0110;


	return &this_(instance);
}
Ejemplo n.º 8
0
            void await_range(TupleIter iter, Iter next, Iter end)
            {
                void (dataflow_frame::*f)(
                        TupleIter, Iter, Iter
                    ) = &dataflow_frame::await_range_respawn;

                for (/**/; next != end; ++next)
                {
                    typedef
                        typename std::iterator_traits<
                            Iter
                        >::value_type
                        future_type;
                    typedef
                        typename traits::future_traits<
                            future_type
                        >::type
                        future_result_type;

                    boost::intrusive_ptr<
                        lcos::detail::future_data<future_result_type>
                    > next_future_data
                        = traits::detail::get_shared_state(*next);

                    if (!next_future_data->is_ready())
                    {
                        next_future_data->execute_deferred();

                        // execute_deferred might have made the future ready
                        if (!next_future_data->is_ready())
                        {
                            boost::intrusive_ptr<dataflow_frame> this_(this);
                            next_future_data->set_on_completed(
                                hpx::util::bind(
                                    f
                                  , std::move(this_)
                                  , std::move(iter)
                                  , std::move(next)
                                  , std::move(end)
                                )
                            );
                            return;
                        }
                    }
                }

                typedef
                    typename boost::fusion::result_of::next<TupleIter>::type
                    next_type;

                do_await(
                    policy_
                  , boost::fusion::next(iter)
                  , boost::mpl::bool_<
                        boost::is_same<next_type, end_type>::value
                    >()
                );
            }
Ejemplo n.º 9
0
    /// \brief Changes the enable and visible states of the child window with the given identifier
    BOOL    ShowAndEnableDlgItem(int idChild, BOOL bShowAndEnable, BOOL bHideIfDisabled)
    {
        BOOL bRet = true;

        if( bShowAndEnable ||
            bHideIfDisabled)
        {
            if(!this_()->ShowDlgItem(idChild, bShowAndEnable))
            {
                bRet = false;
            }
        }

        if(!this_()->EnableDlgItem(idChild, bShowAndEnable))
        {
            bRet = false;
        }

        return bRet;
    }
Ejemplo n.º 10
0
            BOOST_FORCEINLINE
            void finalize(Executor& exec)
            {
                typedef
                    boost::mpl::bool_<boost::is_void<result_type>::value>
                    is_void;

                execute_function_type f = &dataflow_frame::execute;
                boost::intrusive_ptr<dataflow_frame> this_(this);

                parallel::executor_traits<Executor>::apply_execute(exec,
                    hpx::util::deferred_call(f, std::move(this_), is_void()));
            }
Ejemplo n.º 11
0
            void respawn_await(Iter && iter, boost::mpl::false_)
            {
                void (dataflow_frame::*f)(Iter &&)
                    = &dataflow_frame::await_respawn;

                boost::intrusive_ptr<dataflow_frame> this_(this);
                threads::register_thread_nullary(
                    util::deferred_call(f, std::move(this_), std::move(iter))
                  , "hpx::lcos::local::dataflow::respawn_await"
                  , threads::pending
                  , true
                  , threads::thread_priority_boost);
            }
Ejemplo n.º 12
0
            void attach(std::size_t i, Future& future)
            {
                typedef
                    typename traits::detail::shared_state_ptr_for<Future>::type
                    shared_state_ptr;

                // Bind an on_completed handler to this future which will wait
                // for the future and will transfer its result to the new
                // future.
                boost::intrusive_ptr<split_continuation> this_(this);
                shared_state_ptr const& state =
                    hpx::traits::detail::get_shared_state(future);

                state->execute_deferred();
                state->set_on_completed(util::deferred_call(
                    &split_continuation::on_ready<Future>, std::move(this_),
                    i, state));
            }
Ejemplo n.º 13
0
            BOOST_FORCEINLINE
            void await_next(std::size_t depth, Iter iter, boost::mpl::true_,
                boost::mpl::false_)
            {
                typedef
                    typename boost::fusion::result_of::next<Iter>::type
                    next_type;

                typedef
                    typename util::decay_unwrap<
                        typename boost::fusion::result_of::deref<Iter>::type
                    >::type
                    future_type;
                future_type &  f_ =
                    boost::fusion::deref(iter);

                typedef
                    typename traits::future_traits<
                        future_type
                    >::type
                    future_result_type;

                boost::intrusive_ptr<
                    lcos::detail::future_data<future_result_type>
                > next_future_data
                    = lcos::detail::get_shared_state(f_);

                if(!next_future_data->is_ready())
                {
                    next_future_data->execute_deferred();

                    // execute_deferred might have made the future ready
                    if (!next_future_data->is_ready())
                    {
                        void (dataflow_frame::*f)(
                                std::size_t, Iter,
                                boost::mpl::true_, boost::mpl::false_
                            ) = &dataflow_frame::await_next_respawn;

                        boost::intrusive_ptr<dataflow_frame> this_(this);
                        next_future_data->set_on_completed(
                            hpx::util::bind(
                                f
                              , std::move(this_)
                              , ++depth
                              , std::move(iter)
                              , boost::mpl::true_()
                              , boost::mpl::false_()
                            )
                        );
                        return;
                    }
                }

                typedef boost::mpl::bool_<
                        boost::is_same<next_type, end_type>::value
                    > is_at_end;

                // re-spawn on a new thread to avoid stack overflows
                if (depth >= HPX_CONTINUATION_MAX_RECURSION_DEPTH)
                {
                    respawn_await(boost::fusion::next(iter), is_at_end());
                    return;
                }

                await(++depth, boost::fusion::next(iter), is_at_end());
            }
Ejemplo n.º 14
0
            void await_range(std::size_t depth, TupleIter iter,
                Iter next, Iter end)
            {
                void (dataflow_frame::*f)(
                        std::size_t, TupleIter, Iter, Iter
                    ) = &dataflow_frame::await_range_respawn;

                for (/**/; next != end; ++next)
                {
                    typedef
                        typename std::iterator_traits<
                            Iter
                        >::value_type
                        future_type;
                    typedef
                        typename traits::future_traits<
                            future_type
                        >::type
                        future_result_type;

                    boost::intrusive_ptr<
                        lcos::detail::future_data<future_result_type>
                    > next_future_data
                        = lcos::detail::get_shared_state(*next);

                    if (!next_future_data->is_ready())
                    {
                        next_future_data->execute_deferred();

                        // execute_deferred might have made the future ready
                        if (!next_future_data->is_ready())
                        {
                            boost::intrusive_ptr<dataflow_frame> this_(this);
                            next_future_data->set_on_completed(
                                boost::bind(
                                    f
                                  , std::move(this_)
                                  , ++depth
                                  , std::move(iter)
                                  , std::move(next)
                                  , std::move(end)
                                )
                            );
                            return;
                        }
                    }
                }

                typedef
                    typename boost::fusion::result_of::next<TupleIter>::type
                    next_type;
                typedef boost::mpl::bool_<
                        boost::is_same<next_type, end_type>::value
                    > is_at_end;

                // re-spawn on a new thread to avoid stack overflows
                if (depth >= HPX_CONTINUATION_MAX_RECURSION_DEPTH)
                {
                    respawn_await(boost::fusion::next(iter), is_at_end());
                    return;
                }

                await(++depth, boost::fusion::next(iter), is_at_end());
            }
Ejemplo n.º 15
0
static void this_(startReception)(bool nextAck) {
	PIR1bits.SSP1IF = 0;
	// next acknowledge is enabled by ACKDT = 0
	SSP1CON2bits.ACKDT = nextAck == true ? 0 : 1;
	// start reception
	SSP1CON2bits.RCEN = 1;
}

static uint8_t this_(read)() {
	// read data from buffer
	return SSP1BUF;
}

static const struct I2C this_(instance) = {
	this_(generateStartCondition),
	this_(generateStopCondition),
	this_(generateRestartCondition),
	this_(isPending),
	this_(startTransmission),
	this_(wasAcknowledged),
	this_(startReception),
	this_(read),
};

const struct I2C* this_(constructor)(
		char slewRateControll,
		char inputThreshold,
		unsigned int clockPeriod,
		uint16_t slaveAddress,
		char generalCallInterrupt,
Ejemplo n.º 16
0
			LONG const& x() const noexcept
			{
				return this_().data().x;
			}
Ejemplo n.º 17
0
			LONG& x() noexcept
			{
				return this_().data().x;
			}
Ejemplo n.º 18
0
			LONG& y() noexcept
			{
				return this_().data().y;
			}
Ejemplo n.º 19
0
 HWND GetDlgItem_(int idChild) const
 {
     return this_()->GetDlgItem(idChild);
 }
Ejemplo n.º 20
0
			LONG const& y() const noexcept
			{
				return this_().data().y;
			}