On Saturday, July 11, 2026 12:22:44 AM Mountain Daylight Time Danni Coy via Digitalmars-d-learn wrote: > Trying to write low latency code, I have a thread that allocates memory > ahead of what I need. > The thread is only needed occasionally, so I was going to try > core.sync.Condition.wait in the threads main loop, so far so good. > > Ok so the realtime thread needs to wake up the memory thread, which uses > core.sync.Condition.notify - the problem is that I have my realtime thread > annotated @nogc.
@nogc is only a few years old at most, and Condition predates it by many years. Not much in druntime or Phobos in general is designed with @nogc in mind. Some stuff has been updated to be marked with @nogc where possible, but it's often the case that no such changes have been made (and of course, in plenty of cases, it can't be, because the GC is actually used). Either way, in the case of something like Condition, adding @nogc at this point would risk breaking code, because it's a class, and it's not final. So, it's possible that someone has derived from it and done something with one or more of the functions which uses the GC. So, even if the base implementation doesn't use the GC in a particular function, it's not possible to mark it with @nogc at this point if we don't want to risk breaking code. Honestly, attributes don't play very well with inheritance, but even when it does work, it's often the case that the class' functions have to have them from the get-go, or adding them later risks breaking existing code. - Jonathan M Davis
