Re: GCancellable hints



On Thu, 2009-08-27 at 16:38 -0400, David Zeuthen wrote:
> On Thu, 2009-08-27 at 08:09 +0000, Benjamin Otte wrote:
> > In an async program, the 
> > same cancellable is often used for multiple calls at the same time. 
> 
> Be careful, however, to avoid using the same cancellable for multiple
> simultaneous operations. The docs clearly state
> 
>  One GCancellable can be used in multiple consecutive operations,
>  but not in multiple concurrent operations.
> 
> And here's why when I asked Alex why this is so
> 
>  <alexl> davidz: Take the case of two readers using the same cancellable
>  <alexl> davidz: the cancel will write to the pipe, etc
>  <alexl> davidz: with the right race condition, phase of the moon
>  etc, we may only wake up one of the threads

Hmmm, it was a long time since I wrote this... I don't immediately see
any race conditions. The fd is level triggered, as is the win32 event,
so two processes should both wake up as long as nobody calls
g_cancellable_reset(). If we assume all implementations using the
"cancelled" signal behave similarly then it *looks* safe, but I'd feel
somewhat unconfortable with it.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]