mirror of
https://github.com/boostorg/beast.git
synced 2025-06-25 03:51:36 +02:00
Remove Boost.Scope dependency from examples
This commit is contained in:
committed by
Mohammad Nejati
parent
c00cca32a4
commit
e55670d0d0
@ -55,28 +55,28 @@ set(BOOST_SRC_DIR ${DEFAULT_BOOST_SRC_DIR} CACHE STRING "Boost source dir to use
|
||||
#-------------------------------------------------
|
||||
# The boost super-project requires one explicit dependency per-line.
|
||||
set(BOOST_BEAST_DEPENDENCIES
|
||||
Boost::asio
|
||||
Boost::assert
|
||||
Boost::bind
|
||||
Boost::config
|
||||
Boost::container
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::endian
|
||||
Boost::intrusive
|
||||
Boost::logic
|
||||
Boost::mp11
|
||||
Boost::optional
|
||||
Boost::preprocessor
|
||||
Boost::smart_ptr
|
||||
Boost::static_assert
|
||||
Boost::static_string
|
||||
Boost::system
|
||||
Boost::throw_exception
|
||||
Boost::type_index
|
||||
Boost::type_traits
|
||||
Boost::winapi
|
||||
)
|
||||
Boost::asio
|
||||
Boost::assert
|
||||
Boost::bind
|
||||
Boost::config
|
||||
Boost::container
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::endian
|
||||
Boost::intrusive
|
||||
Boost::logic
|
||||
Boost::mp11
|
||||
Boost::optional
|
||||
Boost::preprocessor
|
||||
Boost::smart_ptr
|
||||
Boost::static_assert
|
||||
Boost::static_string
|
||||
Boost::system
|
||||
Boost::throw_exception
|
||||
Boost::type_index
|
||||
Boost::type_traits
|
||||
Boost::winapi)
|
||||
|
||||
foreach (BOOST_BEAST_DEPENDENCY ${BOOST_BEAST_DEPENDENCIES})
|
||||
if (BOOST_BEAST_DEPENDENCY MATCHES "^[ ]*Boost::([A-Za-z0-9_]+)[ ]*$")
|
||||
list(APPEND BOOST_BEAST_INCLUDE_LIBRARIES ${CMAKE_MATCH_1})
|
||||
@ -87,7 +87,7 @@ if (BOOST_BEAST_BUILD_TESTS)
|
||||
set(BOOST_BEAST_UNIT_TEST_LIBRARIES filesystem)
|
||||
endif ()
|
||||
if (BOOST_BEAST_BUILD_EXAMPLES)
|
||||
set(BOOST_BEAST_EXAMPLE_LIBRARIES scope json)
|
||||
set(BOOST_BEAST_EXAMPLE_LIBRARIES json)
|
||||
endif ()
|
||||
# Complete dependency list
|
||||
set(BOOST_INCLUDE_LIBRARIES ${BOOST_BEAST_INCLUDE_LIBRARIES} ${BOOST_BEAST_UNIT_TEST_LIBRARIES} ${BOOST_BEAST_EXAMPLE_LIBRARIES})
|
||||
|
@ -20,7 +20,7 @@ target_include_directories(advanced-server-flex-awaitable
|
||||
PRIVATE ${PROJECT_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(advanced-server-flex-awaitable
|
||||
PRIVATE Boost::beast Boost::scope OpenSSL::SSL OpenSSL::Crypto)
|
||||
PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto)
|
||||
|
||||
set_target_properties(advanced-server-flex-awaitable
|
||||
PROPERTIES FOLDER "example-advanced-server")
|
||||
|
@ -12,7 +12,6 @@ import ac ;
|
||||
project
|
||||
: requirements
|
||||
[ ac.check-library /boost/beast/test//lib-asio-ssl : <library>/boost/beast/test//lib-asio-ssl/<link>static : <build>no ]
|
||||
<library>/boost/scope//boost_scope
|
||||
;
|
||||
|
||||
exe advanced-server-flex-awaitable :
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <boost/asio/ssl.hpp>
|
||||
#include <boost/beast.hpp>
|
||||
#include <boost/beast/ssl.hpp>
|
||||
#include <boost/scope/scope_exit.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
@ -243,17 +242,42 @@ public:
|
||||
auto lg = std::lock_guard{ mtx_ };
|
||||
auto cs = css_.emplace(css_.end());
|
||||
|
||||
class remover
|
||||
{
|
||||
task_group* tg_;
|
||||
decltype(css_)::iterator cs_;
|
||||
|
||||
public:
|
||||
remover(
|
||||
task_group* tg,
|
||||
decltype(css_)::iterator cs)
|
||||
: tg_{ tg }
|
||||
, cs_{ cs }
|
||||
{
|
||||
}
|
||||
|
||||
remover(remover&& other) noexcept
|
||||
: tg_{ std::exchange(other.tg_, nullptr) }
|
||||
, cs_{ other.cs_ }
|
||||
{
|
||||
}
|
||||
|
||||
~remover()
|
||||
{
|
||||
if(tg_)
|
||||
{
|
||||
auto lg = std::lock_guard{ tg_->mtx_ };
|
||||
if(tg_->css_.erase(cs_) == tg_->css_.end())
|
||||
tg_->cv_.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return net::bind_cancellation_slot(
|
||||
cs->slot(),
|
||||
net::consign(
|
||||
std::forward<CompletionToken>(completion_token),
|
||||
boost::scope::make_scope_exit(
|
||||
[this, cs]()
|
||||
{
|
||||
auto lg = std::lock_guard{ mtx_ };
|
||||
if(css_.erase(cs) == css_.end())
|
||||
cv_.cancel();
|
||||
})));
|
||||
remover{ this, cs }));
|
||||
}
|
||||
|
||||
/** Emits the signal to all child tasks and invokes the slot's
|
||||
|
Reference in New Issue
Block a user