[m-users.] Uncomplete documentation of thread.channel and thread.closeable_channel
Peter Wang
novalazy at gmail.com
Fri Apr 10 15:00:21 AEST 2026
On Thu, 09 Apr 2026 14:24:01 +0200 Volker Wysk <post at volker-wysk.de> wrote:
> Hi!
>
> Reading the API docs of thread.channel gives the impression that a channel
> can't be destroyed. What about the ressources associated with the channel?
> Wouldn't it lead to ressource leak if a program repeatedly creates channels,
> that finally aren't used any longer?
The API doesn't require channels to be explicitly destroyed.
In terms of the implementation, a channel consists of a couple of mvars,
which are implemented with semaphores. On C backends, semaphores are
implemented with mutexes and condition variables; we register a
GC finaliser to destroy those when the semaphore is collected.[1]
On the Java and C# backends, semaphores don't need explicit cleanup
either.
Peter
[1] On Linux, I belive pthread_mutex_destroy and pthread_cond_destroy
effectively do nothing.
More information about the users
mailing list