Subject: Re: [boost] [asio] Pass some parameter to io_service::run
From: James Mansion (james_at_[hidden])
Date: 2010-01-10 04:51:24
Dmytro Ovdiienko wrote:
> 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.
> In this case I should create LargeObject for every socket because I don't
> know what thread of the pool will process incoming message. And I cannot
> pass the same largeObject to two or more recv operations.
> Looks like I should use null_buffers. What is overhead of this way? Should I
> go to the kernel twise (1st - socket::async_recv, 2nd - socket::recv)?
I'm confused by the first two statements.
Is the large object 'large' because it is the receive buffer, or does it
contain temporary application
I guess the question is whether the object is owned by:
- the IO operation while it is in progress
- the socket
- the completion handler thread while it handles the completion
If it contains the buffer and you don't want to pre-allocate lots of
them (ie when you start the IO)
then the null buffer optimisation may help, but I'm surprised you would
need to have enough UDP
end points that this is an issue - surely one uses UDP to enable
multiplexing lots of client systems
to each endpoint? You probably don't need bufers larger than a jumbo
fram anyway do you?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk