Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-12-02 04:25:37


In message <90918a+gred_at_[hidden]>, William Kempf <sirwillard_at_my-
deja.com> writes
>> There truly is. Some of the commonest such bindings, eg event-based
>> callbacks, use pointers rather than objects by value.
>
>This makes little difference. So the modification of the state is
>indirect instead of direct for some cases, this doesn't eliminate the
>problem.

Yes, this makes the world of difference. It means that the function
object is not, as you claim, changing its own state. Of course, this
does not eliminate synchronisation issues, and it would be foolish to
think that. However, it does show (unless you wish to quibble with the
definition of show ;->) that the responsibility for thread
synchronisation is not the responsibility either of the function wrapper
we are discussing or of the function object or function that the user
provides. Can we agree on that?

>The callback can't insure any sort of thread
>> >safety for the copy process when a deep copy is performed, while
>it
>> >can be insured for shallow ref-counted copies.
>>
>> I believe you have this back to front. Perhaps you would like to
>> demonstrate what you are thinking with a code fragment -- English
>does
>> not seem to be serving us well ;->

<sigh> This is not code :-(

>A deep copy requires copying of all state that may be contained
>within a function object. This copying of state must be thread safe
>in order for the copying of the function object to be thread safe.
>These state objects are not a part of the function object library,
>but are data types created by the programmer outside of the library.
>Thus the library can not gaurantee that copy of these state objects
>is thread safe. Thus the library can not gaurantee that copying the
>function object is thread safe.

If I understand you correctly, are you saying that on execution of the
ctor there are potentially two threads running through the object? Only
if you've got a bug in your program! Copying rather than sharing of
objects is well recognised as a safe way to pass information around a
program. If what you said was true, we would not be able to program with
strings, ints, etc. However, what you say is not true. Programming with
threads and objects contains a number of pitfalls, and I believe you
have fallen into one of them :-(

Kevlin
____________________________________________________________

  Kevlin Henney phone: +44 117 942 2990
  Curbralan Limited mobile: +44 7801 073 508
  mailto:kevlin_at_[hidden] fax: +44 870 052 2289
  http://www.curbralan.com
____________________________________________________________


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