Thanks Eliot.
Nice idea to return the result.
What didn���t work for me was to only suspend the process in #forBlock:priority:. I had to send #terminate instead. There are two main reasons:
1. #isTerminating (not #isTerminated) will not be correctly set if #terminate hasn���t been sent
2. when signalling the semaphore I want *all* processes that are waiting to be signalled so that the terminating process can���t be preempted while signalling the semaphore. Otherwise it may resume a higher priority process that will not allow the other processes still waiting on the semaphore to run. To do this I have to use different approaches for active and inactive processes, such that #isTerminated is always true when the termination semaphore has been signalled.
I���d appreciate it if you could take a look. Maybe you���ll spot something I could have done better.
Cheers,
Max