On Wed, Feb 14, 2018 at 04:31:45PM -0600, Eric Blake wrote:
> On 02/14/2018 08:06 AM, Stefan Hajnoczi wrote:
> > On Tue, Feb 13, 2018 at 10:01:06AM -0600, Eric Blake wrote:
> > I hope this explains things!  The main issue that raised these questions
> > was that aio_context_in_iothread() has a misleading name.  Shall we
> > rename it?
> 
> Maybe, but that's a separate patch.  What name would we bikeshed, maybe
> aio_context_correct_thread() (we are the correct thread if we are the
> iothread that owns ctx, or if we are the main thread and have properly
> acquired ctx) 

Having acquired the AioContext does not make this function return true.
The semantics are:
1. Current thread is the IOThread that runs the AioContext
2. Current thread is the main loop and the AioContext is the global
   AioContext.

The function tests whether the current thread is the "native" or "home"
thread for this AioContext.  Perhaps we could also call it the "poller"
thread because only that thread is allowed to call aio_poll(ctx, true).

  if (aio_context_in_native_thread(ctx)) {
      ...
  } else {
      ...
  }

What do you think?

Attachment: signature.asc
Description: PGP signature

Reply via email to