Boost logo

Boost :

From: Giovanni P. Deretta (gpderetta_at_[hidden])
Date: 2006-02-07 00:39:08


Stefan Seefeld wrote:
> Giovanni P. Deretta wrote:
>
>>Stefan Seefeld wrote:
>>
>>
>>>Giovanni P. Deretta wrote:
>>>
>>>
>>>
>>>
>>>>You could argue that as this is a useful behavior stream_socket should
>>>>have pointer semantics by default and be reference counted. But you
>>>>would force the space and time overhead of a shared_ptr to everybody
>>>>(btw, shared_ptr still require dynamic allocation of the reference
>>>>counter).
>>>
>>>
>>>If users would always only hold references to the real resource, how
>>>would they declare interest in a 'ready-for-read' event, and which of
>>>the references would receive it ?
>>>
>>
>>
>>I do not understand exactly what you are asking? Could you eleaborate?
>
>
> As far as I understand the above suggestion, sockets (streams) having
> reference semantics (or be copyable) implies that multiple objects
> exist that refer to the same underlaying 'device'.
>
> If the system has data ready to be read for that device, which reference
> should it dispatch them to ?
>
Well the system does not dispatch readiness messages to handles, but you
register an handle with a callback to receive notification.
If you register multiple handles, all of them get the notification.
Anyway, even if you have multiple copies of an handle, you should'n use
more than one at once expecially from multiple threads and expecially
stream handles (actually using the same datagram socket or accept socket
from multiple threads should be fine)

BTW, I was not the one arguing in favor of copyable sockets.

-- 
Giovanni P. Deretta

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk