Oh, my GoD! Goroutines on D

claptrap clap at trap.com
Wed Jan 8 10:16:58 UTC 2025


On Wednesday, 8 January 2025 at 10:10:55 UTC, Jin wrote:
> On Monday, 6 January 2025 at 10:15:39 UTC, Jin wrote:
>> I found a bug. I first checked if there was anything in the 
>> queue, and if not, I checked if the queue was finalized. 
>> Sometimes the queue would fill up between these two steps and 
>> I would lose data. I moved the finalization check to the 
>> beginning and now everything is stable.
>
> I looked into the core.atomic code and was very disappointed. I 
> expected to see memory barriers (necessary for wait-free), but 
> I saw a CAS-spinlock there (and this is lock-free):

Technically it is lock free but not wait free. No thread can 
actually hold it like a regular lock, the CAS either succeeds or 
of fails in one go, so you are always guaranteed at least one 
thread will progress.


More information about the Digitalmars-d mailing list