Active Object pattern using boost::asio

Today I was searching on the Internet for some Active Object pattern examples. And I found blog by Dean Berris:
http://cplusplus-soup.com/2006/12/06/boost-asio-and-patterns/

so I decided to make modifications and release code as working example.

To put it simple: active object owns its own private thread, and runs all of its work on that private thread.
What we gain from constructing such an object? First a caller can invoke some object methods and these methods are nonblocking: callers return immediately. In other words - asynchronous calls. Main thread at the same time can proceed, for example, with GUI event handling. When active object's thread, working in background, is done with heavy duty task, it just join main thread, before leaving scope.
C++ snippet of working example is shown bellow (tested with g++ 4.4):

#include    
#include    
#include    
#include    
#include    
#include    
#include    
#include    
#include    
 
class ActiveObject : boost::noncopyable
{
    public:
        ActiveObject() : work_(service_)
        {
            executionThread_.reset( new boost::thread(boost::bind(&boost::asio::io_service::run, &service_)) );
        }
 
        virtual ~ActiveObject()
        { 
            service_.poll();
            service_.stop();
            executionThread_->join();
            std::cout << "destroying active object" << std::endl;
        }
 
        void doSomething(const std::string& workName)
        {
            service_.post( boost::bind(&ActiveObject::someImpl, this, workName) );
        }
        
    protected:
        boost::asio::io_service service_;
    
    private:
        boost::asio::io_service::work work_;
        boost::shared_ptr executionThread_;
        boost::mutex mutex_;
 
        void someImpl(const std::string& name)
        {
            boost::lock_guard lk(mutex_);
            std::cout << "Doing work: " << name << std::endl; 
        }
};
 
int main()
{
    boost::shared_ptr pobj = boost::shared_ptr< ActiveObject >(new ActiveObject());
    
    pobj->doSomething("first");
    pobj->doSomething("second");
    
    std::cout << "end of main thread: " << std::endl;
    return 0;
}
or http://codepaste.net/n12fd4
happy coding!