Send from the strand

This commit is contained in:
Vinnie Falco
2019-01-21 16:07:00 -08:00
parent 2dcb11b89a
commit 383b9cb7f2
2 changed files with 17 additions and 0 deletions

View File

@ -1,3 +1,9 @@
Version 207
* Send from the strand
--------------------------------------------------------------------------------
Version 206
* Clear error codes idiomatically

View File

@ -90,6 +90,17 @@ void
websocket_session::
send(boost::shared_ptr<std::string const> const& ss)
{
// Get on the strand if we aren't already,
// otherwise we will concurrently access
// objects which are not thread-safe.
if(! strand_.running_in_this_thread())
return net::post(
net::bind_executor(strand_,
std::bind(
&websocket_session::send,
shared_from_this(),
ss)));
// Always add to queue
queue_.push_back(ss);