Unused druntime code: Barrier, ReadWriteMutex, Condition
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Mon Jun 15 09:07:54 UTC 2026
On 15/06/2026 9:36 AM, Denis Feklushkin wrote:
> While working on FreeRTOS support several years ago I discovered that
> druntime's classes Barrier, ReadWriteMutex and Condition weren't used at
> druntime or by compiler (CI with mentioned classes disabled https://
> github.com/dlang/dmd/pull/23265)
>
> In fact, Barrier and ReadWriteMutex aren't used at all in any std D
> libraries or by compiler and Condition is used only in Phobos.
>
> They all rely on Condition. The problem with it is that Condition uses
> primitive provided by the OS (pthread_condattr if Posix). However, not
> all operating systems provide this primitive (FreeRTOS for example) and
> this causes a problem out of nowhere.
>
> Since this code is not necessary for Dlang's core functionality, I
> propose moving all mentioned classes to Phobos with appropriate warning
> messages
Here is a "standard" addon that gets mentioned for FreeRTOS for read
write mutex:
https://github.com/michaelbecker/freertos-addons/blob/master/c/Source/read_write_lock.c
Condition:
https://github.com/michaelbecker/freertos-addons/blob/master/c%2B%2B/Source/ccondition_variable.cpp
There are enough primitives in FreeRTOS to build these other sync
primitives.
If you don't want to implement these two types, feel free to version it
off. Let's not go breaking existing code bases.
More information about the Digitalmars-d
mailing list