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
--- Begin Message ---
> > 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

--- End Message ---

Reply via email to