[Spice-devel] [PATCH spice-gtk 11/13] coroutine: reference object when signaling

Christophe Fergeau cfergeau at redhat.com
Thu Nov 13 00:25:32 PST 2014


On Wed, Nov 12, 2014 at 12:46:40PM -0500, Marc-André Lureau wrote:
> 
> 
> ----- Original Message -----
> > On Wed, Nov 12, 2014 at 12:10:26PM -0500, Marc-André Lureau wrote:
> > > 
> > > 
> > > ----- Original Message -----
> > > > Hey,
> > > > 
> > > > On Sun, Nov 09, 2014 at 05:31:43PM +0100, Marc-André Lureau wrote:
> > > > > Before the signal is acutally emitted, the channel may be
> > > > 
> > > > 'actually'
> > > > 
> > > > > released. Similarly to g_signal_emit, take a reference before yielding
> > > > > to main context.
> > > > 
> > > > I would drop the "similarly to g_signal_emit" as your purpose is most
> > > > likely different. The ref is needed here as the signal emission is
> > > > async, so code can run before the signal emission, but g_signal_emit is
> > > > synchronous.
> > > > 
> > > > I assume the scenario you want to protect against is
> > > > - (coroutine context)g_coroutine_signal_emit is called
> > > >   - the signal emission is scheduled in an idle with g_idle_add
> > > >   - coroutine_yield() is called
> > > > - (main context)code runs which drops the last ref on the channel
> > > > - (main context)idle runs and tries to emit the signal
> > > > 
> > > > 
> > > > Patch looks good if this is the correct scenario.
> > > 
> > > Yes, I maintain "similarly", because we want to maintain object alive
> > > during g_coroutine_signal_emit(). I think it is thus appropriate here.
> > 
> > g_signal_emit and g_coroutine_signal_emit want to keep the object alive
> > for very different reasons, so I would not say "similarly". The only
> 
> g_coroutine_signal_emit() and g_signal_emit() both want to keep object alive during the function time.
> 
> Anyway, I don't think it's worth arguing about your interpretation, I rephrase:
> 
> "Let's keep a reference to the object during
> the function time, to prevent the object from being destroyed before
> calling g_signal_emit() in main context."

Works for me, ACK.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20141113/63148efd/attachment.sig>


More information about the Spice-devel mailing list