Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-04-20 18:16:21


AMDG

Rene Rivera <grafikrobot <at> gmail.com> writes:

>
> Sohail Somani wrote:
> >> Steven Watanabe wrote:
> >>> It's not thread safe and the only way I can
> >>> see to make it so is to have a fixed set
> >>> of functions and allocate/deallocate
> >> Why would it need to be thread safe? Usually one puts thread safety
> >> above this kind of utility layer.
> >
> > Well if you need to implement a C-callback that doesn't have a void *
> > data argument.
>
> You put the thread safety in what the c-function calls. Now if the
> question really is that the setting of the function object instance
> isn't thread safe... You would make the code that calls make_c_function
> thread safe, by using locks for example. Note, calling the c-function,
> and hence the function object, is thread safe AFAIK.
>

That isn't what I meant. If

void(*f)();
{
scoped_lock lock(m);
f = make_c_function(...);
}
use f

were sufficient I wouldn't have a problem.

Unfortunatly, it is necessary to retain the lock
until you are done with f.

In Christ,
Steven Watanabe


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