|
Boost : |
Subject: Re: [boost] [asio] Pass some parameter to io_service::run
From: Sergei Politov (spolitov_at_[hidden])
Date: 2010-01-10 00:48:09
Hi,
>
> I need to pass reference to this object to the socket::async_receive
> complete routine to complete message processing. This object allocates a
> lot
> of memory and I cannot create it for every socket. It is possible to create
> but there is no sense.
>
You can pass them using boost::bind:
socket_.async_read_some(boost::asio::buffer(data_, max_length),
boost::bind(&session::handle_read, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred,
boost::ref(largeObject)));
Where:
void session::handle_read(const boost::system::error_code& error, size_t
bytes_transferred, LargeObject & largeObject)
{
......
}
Best Regards,
Sergei
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk