// (C) Copyright Mac Murrett 2001. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org for most recent version. #ifndef BOOST_REMOTE_CALL_MANAGER_MJM012402_HPP #define BOOST_REMOTE_CALL_MANAGER_MJM012402_HPP #include #include "delivery_man.hpp" #include "dt_scheduler.hpp" #include "periodical.hpp" #include "execution_context.hpp" #include "st_scheduler.hpp" namespace boost { namespace threads { namespace mac { namespace detail { // class remote_call_manager is used by the remote call functions (dt_remote_call and // st_remote_call) to execute functions in non-MP contexts. class remote_call_manager: private noncopyable { protected: remote_call_manager(); ~remote_call_manager(); public: template R execute_at_dt(function &rFunctor); template R execute_at_st(function &rFunctor); private: template static R execute_now(function &rFunctor); private: delivery_man m_oDTDeliveryMan; delivery_man m_oSTDeliveryMan; function m_oDTFunction; function m_oSTFunction; periodical m_oDTPeriodical; periodical m_oSTPeriodical; }; template /*static*/ inline R remote_call_manager::execute_now(function &rFunctor) { return(rFunctor()); } template<> /*static*/ inline void remote_call_manager::execute_now(function &rFunctor) { rFunctor(); } template inline R remote_call_manager::execute_at_dt(function &rFunctor) { if(at_mp()) { return(m_oDTDeliveryMan.deliver(rFunctor)); } return(execute_now(rFunctor)); } template inline R remote_call_manager::execute_at_st(function &rFunctor) { if(at_mp()) { return(m_oSTDeliveryMan.deliver(rFunctor)); } assert(at_st()); return(execute_now(rFunctor)); } } // namespace detail } // namespace mac } // namespace threads } // namespace boost #endif // BOOST_REMOTE_CALL_MANAGER_MJM012402_HPP