Boost logo

Boost :

Subject: [boost] [ASIO] example clarification (how to)
From: Gaetano Mendola (mendola_at_[hidden])
Date: 2013-12-21 16:09:32

In the asio chat example

the class chat_server implements the async_accept handler with a lambda
without use the shared_from_this pattern, isn't an error destroy the
class while the handler is running? Maybe is not a problem looking at
how is used inside the main but without having knowledge on how is it
going to be used which can be the best way to destroy the chat_server
(or similar code) safely? Is something like the following correct?

chat_server::~chat_server() {
   //Call dispatching a cancel operation
   //in order to be sure to not chain another async_accept

here I'm supposing a single thread is running otherwise
the strand has to be used.

Gaetano Mendola

This email is free from viruses and malware because avast! Antivirus protection is active.

Boost list run by bdawes at, gregod at, cpdaniel at, john at