9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Mathieu Lonjaret" <mathieu.lonjaret@gmail.com>
To: 9fans@9fans.net
Subject: Re: [9fans] alt and chanfree
Date: Wed, 15 Sep 2010 10:15:10 +0200	[thread overview]
Message-ID: <4f594cbed02febd4f1086a3bf4b13bd9@iram.fr> (raw)
In-Reply-To: <5b73ce333ceed4d8bb71f0e017f70cca@plug.quanstro.net>

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]

I haven't tried chanclose() yet, but setting to nil the freed chan in the
alt entry is not really what I wanted since it will make alt() return -1
(better than crashing but not ideal).
In any case I found a satisfying workaround in my algorithm to solve that:
when a thread is done using a chan, I keep track of it instead of calling
chanfree(), and instead of allocating a new chan/alt when creating a new
thread, I simply reuse one of the previously "abandonned" ones (if any
is available). And I'll just free them all when the program terminates.

Thanks to all,
Mathieu

[-- Attachment #2: Type: message/rfc822, Size: 4032 bytes --]

From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] alt and chanfree
Date: Tue, 14 Sep 2010 10:17:13 -0400
Message-ID: <5b73ce333ceed4d8bb71f0e017f70cca@plug.quanstro.net>

> > isn't that what chanclose()/chanclosing() is for?
> >
> > - erik
> >
> >
>
> Not at all. Chanclose and chanclosing are to be used while the channel
> still exists.
> A closed channel is not a freed channel. Close/closing are useful for
> synchronizing the cleanup
> but no other operation should be done on a channel after it has been
> freed because
> the channel no longer exists.

of course i ment using chanclose as the first step.  the
thread running the alt can free the closed channel.

- erik

  reply	other threads:[~2010-09-15  8:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-14  8:57 Mathieu Lonjaret
2010-09-14  9:55 ` roger peppe
2010-09-14 10:04   ` Mathieu Lonjaret
2010-09-14 13:01     ` erik quanstrom
2010-09-14 13:27       ` Mathieu Lonjaret
2010-09-14 13:30         ` erik quanstrom
2010-09-14 13:46           ` Mathieu Lonjaret
2010-09-14 13:49         ` Gorka Guardiola
2010-09-14 14:17           ` erik quanstrom
2010-09-15  8:15             ` Mathieu Lonjaret [this message]
2010-09-15  9:47               ` roger peppe
2010-09-15 11:07                 ` Mathieu Lonjaret

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=4f594cbed02febd4f1086a3bf4b13bd9@iram.fr \
    --to=mathieu.lonjaret@gmail.com \
    --cc=9fans@9fans.net \
    /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).