DispatchSemaphore and DispatchQueue/DispatchGroup on non-Darwin platforms

I am a little confused about the use of DispatchSemaphore, DispatchQueue, and DispatchGroup on non-Darwin platforms, especially on Windows.

I know that they are available on Windows when importing the full Foundation, even with Swift 6.2. But I could not find their implementation in the Swift Foundation code. Some older post say that they are only available on the Darwin platforms, but this is apparently not true.

So I hope they will not go away on Linux and on Windows? The reason that I am concerned about them that I need them to be able to work with @unchecked Sendable functions which use them as tools, which is an important way to organize concurrent access to a resource also usable in a synchronous environment. Without those tools there is not much left to do this.

(I think this problem is a little bit part of the broader topic, that is does not seem to be well-documented what should be implemented where in the long term, see my other question about FileHandle in FoundationEssentials .)

libdispatch is actually a different library completely from Foundation, so it makes sense that Foundation wouldn’t have the code for them.

1 Like