]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common/async: add spawn_throttle for bounded concurrency with optional_yield
authorCasey Bodley <cbodley@redhat.com>
Wed, 8 May 2024 16:42:42 +0000 (12:42 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 22 May 2024 21:02:15 +0000 (17:02 -0400)
commit0da024f92813323b58048947172f7d499701c55d
treef8cf3eee5b27b40be66ce5e4258562a91079b536
parente4d5b4e937b03e72356c21cdf9b4d24459080c35
common/async: add spawn_throttle for bounded concurrency with optional_yield

a primitive for structured concurrency with stackful coroutines from
boost::asio::spawn(). this relies on spawn()'s support for per-op
cancellation to guarantee that the lifetime of child coroutines won't
exceed the lifetime of their spawn_throttle, making it safe for children
to access memory from their parent's stack

by taking optional_yield in the constructor, spawn_throttle transparently
supports synchronous execution (where optional_yield is empty) and
asynchronous execution within a stackful coroutine (where optional_yield
contains the parent's yield_context)

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/common/async/detail/spawn_throttle_impl.h [new file with mode: 0644]
src/common/async/spawn_throttle.h [new file with mode: 0644]
src/test/common/CMakeLists.txt
src/test/common/test_async_spawn_throttle.cc [new file with mode: 0644]