mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +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.
|
# The boost super-project requires one explicit dependency per-line.
|
||||||
set(BOOST_BEAST_DEPENDENCIES
|
set(BOOST_BEAST_DEPENDENCIES
|
||||||
Boost::asio
|
Boost::asio
|
||||||
Boost::assert
|
Boost::assert
|
||||||
Boost::bind
|
Boost::bind
|
||||||
Boost::config
|
Boost::config
|
||||||
Boost::container
|
Boost::container
|
||||||
Boost::container_hash
|
Boost::container_hash
|
||||||
Boost::core
|
Boost::core
|
||||||
Boost::endian
|
Boost::endian
|
||||||
Boost::intrusive
|
Boost::intrusive
|
||||||
Boost::logic
|
Boost::logic
|
||||||
Boost::mp11
|
Boost::mp11
|
||||||
Boost::optional
|
Boost::optional
|
||||||
Boost::preprocessor
|
Boost::preprocessor
|
||||||
Boost::smart_ptr
|
Boost::smart_ptr
|
||||||
Boost::static_assert
|
Boost::static_assert
|
||||||
Boost::static_string
|
Boost::static_string
|
||||||
Boost::system
|
Boost::system
|
||||||
Boost::throw_exception
|
Boost::throw_exception
|
||||||
Boost::type_index
|
Boost::type_index
|
||||||
Boost::type_traits
|
Boost::type_traits
|
||||||
Boost::winapi
|
Boost::winapi)
|
||||||
)
|
|
||||||
foreach (BOOST_BEAST_DEPENDENCY ${BOOST_BEAST_DEPENDENCIES})
|
foreach (BOOST_BEAST_DEPENDENCY ${BOOST_BEAST_DEPENDENCIES})
|
||||||
if (BOOST_BEAST_DEPENDENCY MATCHES "^[ ]*Boost::([A-Za-z0-9_]+)[ ]*$")
|
if (BOOST_BEAST_DEPENDENCY MATCHES "^[ ]*Boost::([A-Za-z0-9_]+)[ ]*$")
|
||||||
list(APPEND BOOST_BEAST_INCLUDE_LIBRARIES ${CMAKE_MATCH_1})
|
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)
|
set(BOOST_BEAST_UNIT_TEST_LIBRARIES filesystem)
|
||||||
endif ()
|
endif ()
|
||||||
if (BOOST_BEAST_BUILD_EXAMPLES)
|
if (BOOST_BEAST_BUILD_EXAMPLES)
|
||||||
set(BOOST_BEAST_EXAMPLE_LIBRARIES scope json)
|
set(BOOST_BEAST_EXAMPLE_LIBRARIES json)
|
||||||
endif ()
|
endif ()
|
||||||
# Complete dependency list
|
# Complete dependency list
|
||||||
set(BOOST_INCLUDE_LIBRARIES ${BOOST_BEAST_INCLUDE_LIBRARIES} ${BOOST_BEAST_UNIT_TEST_LIBRARIES} ${BOOST_BEAST_EXAMPLE_LIBRARIES})
|
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})
|
PRIVATE ${PROJECT_SOURCE_DIR})
|
||||||
|
|
||||||
target_link_libraries(advanced-server-flex-awaitable
|
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
|
set_target_properties(advanced-server-flex-awaitable
|
||||||
PROPERTIES FOLDER "example-advanced-server")
|
PROPERTIES FOLDER "example-advanced-server")
|
||||||
|
@ -12,7 +12,6 @@ import ac ;
|
|||||||
project
|
project
|
||||||
: requirements
|
: requirements
|
||||||
[ ac.check-library /boost/beast/test//lib-asio-ssl : <library>/boost/beast/test//lib-asio-ssl/<link>static : <build>no ]
|
[ 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 :
|
exe advanced-server-flex-awaitable :
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <boost/asio/ssl.hpp>
|
#include <boost/asio/ssl.hpp>
|
||||||
#include <boost/beast.hpp>
|
#include <boost/beast.hpp>
|
||||||
#include <boost/beast/ssl.hpp>
|
#include <boost/beast/ssl.hpp>
|
||||||
#include <boost/scope/scope_exit.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -243,17 +242,42 @@ public:
|
|||||||
auto lg = std::lock_guard{ mtx_ };
|
auto lg = std::lock_guard{ mtx_ };
|
||||||
auto cs = css_.emplace(css_.end());
|
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(
|
return net::bind_cancellation_slot(
|
||||||
cs->slot(),
|
cs->slot(),
|
||||||
net::consign(
|
net::consign(
|
||||||
std::forward<CompletionToken>(completion_token),
|
std::forward<CompletionToken>(completion_token),
|
||||||
boost::scope::make_scope_exit(
|
remover{ this, cs }));
|
||||||
[this, cs]()
|
|
||||||
{
|
|
||||||
auto lg = std::lock_guard{ mtx_ };
|
|
||||||
if(css_.erase(cs) == css_.end())
|
|
||||||
cv_.cancel();
|
|
||||||
})));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Emits the signal to all child tasks and invokes the slot's
|
/** Emits the signal to all child tasks and invokes the slot's
|
||||||
|
Reference in New Issue
Block a user