Example #1
0
inline void spawn(
  spawn_type spw,
  actor<stackless>& sire, match_t func, SpawnHandler h,
  match_t ctxid = ctxid_nil,
  link_type type = no_link,
  std::size_t stack_size = default_stacksize(),
  seconds_t tmo = seconds_t(GCE_DEFAULT_REQUEST_TIMEOUT_SEC)
  )
{
  aid_t aid;
  sid_t sid = sire.spawn(spw, func, ctxid, stack_size);
  boost::uint16_t err = 0;
  sid_t ret_sid = sid_nil;

  duration_t curr_tmo = tmo;
  typedef boost::chrono::system_clock clock_t;
  clock_t::time_point begin_tp = clock_t::now();
  match mach(curr_tmo);
  mach.match_list_.push_back(detail::msg_spawn_ret);
  sire.recv(
    boost::bind(
      &handle_remote_spawn, _1, _2, _3,
      type, begin_tp, sid, tmo, curr_tmo, spawn_handler_t(h)
      ),
    mach
    );
}
Example #2
0
inline aid_t spawn(
  threaded_actor sire, F f,
  link_type type = no_link,
  size_t stack_size = default_stacksize()
  )
{
  return detail::spawn(Tag(), sire, f, false, type, stack_size);
}
Example #3
0
inline aid_t spawn(
  stackful_actor sire, F f,
  link_type type = no_link,
  bool sync_sire = false,
  size_t stack_size = default_stacksize()
  )
{
  return detail::spawn(Tag(), sire, f, sync_sire, type, stack_size);
}
///----------------------------------------------------------------------------
void coroutine_stackful_actor::start(std::size_t stack_size)
{
  if (stack_size < minimum_stacksize())
  {
    stack_size = minimum_stacksize();
  }
  else if (stack_size > default_stacksize())
  {
    stack_size = default_stacksize();
  }

  boost::asio::spawn(
    snd_,
    boost::bind(
      &coroutine_stackful_actor::run, this, _1
      ),
    boost::coroutines::attributes(stack_size)
    );
}
Example #5
0
inline void spawn_remote(
  stackless_actor sire, std::string const& func, SpawnHandler h,
  Match ctxid,
  link_type type = no_link,
  size_t stack_size = default_stacksize(),
  duration_t tmo = seconds(GCE_DEFAULT_REQUEST_TIMEOUT_SEC)
  )
{
  detail::spawn_remote(Tag(), sire, func, h, to_match(ctxid), type, stack_size, tmo);
}
Example #6
0
inline aid_t spawn_remote(
  ActorRef sire, std::string const& func,
  Match ctxid,
  link_type type = no_link,
  size_t stack_size = default_stacksize(),
  duration_t tmo = seconds(GCE_DEFAULT_REQUEST_TIMEOUT_SEC)
  )
{
  return detail::spawn_remote(Tag(), sire, func, to_match(ctxid), type, stack_size, tmo);
}
            void* allocate(std::size_t size) const
            {
                HPX_ASSERT(default_stacksize() <= size);

                void* limit = __splitstack_makecontext(size, segments_ctx_, &size);
                if (!limit) boost::throw_exception(std::bad_alloc());

                int off = 0;
                 __splitstack_block_signals_context(segments_ctx_, &off, 0);

                return static_cast<char *>(limit) + size;
            }
void
segmented_stack_allocator::allocate( stack_context & ctx, std::size_t size)
{
    BOOST_ASSERT( default_stacksize() <= size);

    void * limit = __splitstack_makecontext( size, ctx.segments_ctx, & ctx.size);
    BOOST_ASSERT( limit);
    ctx.sp = static_cast< char * >( limit) + ctx.size;

    int off = 0;
     __splitstack_block_signals_context( ctx.segments_ctx, & off, 0);
}
Example #9
0
inline void spawn_remote(
  stackless_actor sire, std::string const& func, aid_t& aid,
  Match ctxid,
  link_type type = no_link,
  size_t stack_size = default_stacksize(),
  duration_t tmo = seconds(GCE_DEFAULT_REQUEST_TIMEOUT_SEC)
  )
{
  typedef context::stackless_actor_t stackless_actor_t;

  stackless_actor_t& a = sire.get_actor();
  detail::spawn_remote(
    stackful(), sire, func, 
    boost::bind(
      &stackless_actor_t::spawn_handler, &a, 
      _arg1, _arg2, boost::ref(aid)
      ), 
    to_match(ctxid), type, stack_size, tmo
    );
}
Example #10
0
inline aid_t spawn(
  threaded_actor sire, F f,
  link_type type = no_link,
  size_t stack_size = default_stacksize()
  )
{
#ifdef GCE_LUA
  typedef typename boost::remove_const<
    typename boost::remove_reference<
      typename boost::remove_volatile<F>::type
      >::type
    >::type param_t;
  typedef typename boost::mpl::if_<
    typename boost::is_same<param_t, char const*>::type, luaed, 
    typename boost::mpl::if_<
      typename boost::is_same<param_t, std::string>::type, luaed, stackful
      >::type
    >::type select_t;
#else
  typedef stackful select_t;
#endif
  return detail::spawn(select_t(), sire, f, false, type, stack_size);
}
Example #11
0
  aid_t sire, remote_func_list_t const& remote_func_list,
  std::string const& ep, bool is_router
  )
{
  BOOST_FOREACH(remote_func_t const& f, remote_func_list)
  {
    remote_func_list_.insert(std::make_pair(f.first, f.second));
  }
  is_router_ = is_router;

  boost::asio::spawn(
    snd_,
    boost::bind(
      &acceptor::run, this, sire, ep, _1
      ),
    boost::coroutines::attributes(default_stacksize())
    );
}
///----------------------------------------------------------------------------
void acceptor::stop()
{
  close();
}
///----------------------------------------------------------------------------
void acceptor::on_free()
{
  base_type::on_free();

  stat_ = ready;
  remote_func_list_.clear();
  is_router_ = false;