Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/boost/capy/ex/detail/strand_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifndef BOOST_CAPY_EX_DETAIL_STRAND_SERVICE_HPP
#define BOOST_CAPY_EX_DETAIL_STRAND_SERVICE_HPP

#include <boost/capy/continuation.hpp>
#include <boost/capy/detail/config.hpp>
#include <coroutine>
#include <boost/capy/ex/executor_ref.hpp>
Expand Down Expand Up @@ -69,14 +70,14 @@ class BOOST_CAPY_DECL strand_service
dispatch(
std::shared_ptr<strand_impl> const& impl,
executor_ref ex,
std::coroutine_handle<> h);
continuation& c);

/** Post to strand queue. */
static void
post(
std::shared_ptr<strand_impl> const& impl,
executor_ref ex,
std::coroutine_handle<> h);
continuation& c);

protected:
strand_service();
Expand Down
8 changes: 5 additions & 3 deletions include/boost/capy/ex/strand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ namespace capy {
thread_pool pool(4);
auto strand = make_strand(pool.get_executor());

// These continuations will never run concurrently
// Continuations are linked intrusively into the strand's queue,
// so each one must outlive its time there. Storage is typically
// owned by the awaitable or operation state that posted it.
continuation c1{h1}, c2{h2}, c3{h3};
strand.post(c1);
strand.post(c2);
Expand Down Expand Up @@ -220,7 +222,7 @@ class strand
void
post(continuation& c) const
{
detail::strand_service::post(impl_, executor_ref(ex_), c.h);
detail::strand_service::post(impl_, executor_ref(ex_), c);
}

/** Dispatch a continuation through the strand.
Expand All @@ -243,7 +245,7 @@ class strand
std::coroutine_handle<>
dispatch(continuation& c) const
{
return detail::strand_service::dispatch(impl_, executor_ref(ex_), c.h);
return detail::strand_service::dispatch(impl_, executor_ref(ex_), c);
}
};

Expand Down
Loading
Loading