I’ve been doing some thread related code lately and just came across a problem. I’m using a semaphore for a producer/consumer solution around a shared resource, the build thread to be exact. So multiple producers are wanting to flag that a build needs to be done, but there’s only one consumer (the actual build thread).
Finished up all the code and then hit play only to find that my build thread ran continuously and never waited. In fact it would run without a call to build! After adding in some checks on return statements I find out that sem_init always fails when trying to create my semaphore: “Function Not Implemented.”
Turns out Apple decided not to implement unnamed semaphores
Instead you’re supposed to use named semaphores. Well I’m not a fan! Named semaphores are available to other processes too. That means that two apps can both open the same named semaphore and interact (note: I haven’t actually tested if apps can ‘actually’ cross boundaries on iOS, but they can on other systems and portability is important for the engine). And since this is in generic engine code, I can’t just pick a really unique name cause it would clash between two or more games based on the same engine.
As the CEO of Yahoo recently stated, “that was certainly a downer.” Guess I’m going to have to come up with my own solution now.



