9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@swtch.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] OT: cannonical set of queue ops
Date: Thu,  7 Dec 2006 16:37:22 -0500	[thread overview]
Message-ID: <ee9e417a0612071337i2850537ep6ae8efa41fa1dab6@mail.gmail.com> (raw)
In-Reply-To: <15215407ef3dbfddfed3946505e2dc78@quintile.net>

I have had a similar problem in some applications
I have written using venti.  As Richard Bilson points out,
the tempting solution is not the best one.

I think that you want to have an explicit "no more sending will happen"
state, the same as a pipe where one end has been closed.
Then the receiving end can get the "EOF" once it has read the
remaining items and can close its side.  Once both sides are closed,
the queue is freed.

There are various ways you could frame things (for example,
you could require that the write side is always closed before
the read side), but no matter what you always end up with
a two-step: first the writer signals he is done (could write an
empty message instead), then the reader cleans up when he
sees he has gotten everything.  Can hide in a library or handle
explicitly.

One reason that having an IsQueueEmpty complicates things is
that allowing the *writer* to check whether the *reader* has gotten
all the messages yet causes information to flow backward
(from reader to writer).

Russ


      parent reply	other threads:[~2006-12-07 21:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-06 16:14 Steve Simon
2006-12-06 16:35 ` Richard Bilson
2006-12-06 22:36   ` LiteStar numnums
2006-12-06 22:58     ` Richard Bilson
2006-12-07  0:07       ` David Leimbach
2006-12-07 21:37 ` Russ Cox [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee9e417a0612071337i2850537ep6ae8efa41fa1dab6@mail.gmail.com \
    --to=rsc@swtch.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).