[libdispatch-dev] Fully functional libdispatch port for Windows and Linux

Dave Zarzycki zarzycki at apple.com
Fri Feb 11 10:39:52 PST 2011


Marius,

Interesting work. Thanks for sharing.

FYI – We _intentionally_ omitted some APIs from the design of GCD that your code adds. For example: "isSuspended()". There is no way any developer can use that API safely in a concurrent environment because the result is instantly stale upon return. Also, the "setSuspended()" API is misleading. Internally, it is a suspend count, not a boolean. That is why we vended "dispatch_suspend()" and "dispatch_resume()" so that multiple clients may safely coordinate suspension without being explicitly aware of each other.

Also, we don't like vending getter APIs that allow developers to implement dubious and/or problematic RTTI like logic. For example, the "isSerialQueue()" method that your C++ wrapper adds. If one needs to submit a non-reentrant block, then use the barrier API that GCD provides and don't bother trying to query the queue type. Similarly, we intentionally didn't vend a "type()" API because we couldn't foresee any way it could be used safely. One should just submit the block with the right combination of desired behavior (dispatch_async, dispatch_sync, dispatch_barrier_async, or dispatch_barrier_sync) and move on.

Thanks again for sharing. :-)

davez


On Feb 11, 2011, at 10:06 AM, Marius Zwicker wrote:

> Hi everyone,
> 
> I'm glad to announce that I finished a port of libdispatch to Linux and Windows during the last days. Except the source interfaces (which differ too much between Windows and Linux) the API should be fully operational. The majority of your original tests is passing - some of them still need to be ported to build and run on all platforms. As I did not manage to understand your code completely, I did a complete rewrite and merely reused your api and general ideas.
> 
> For achieving "blocks support" on the majority of the used compilers I added lambda support from the upcoming C++0x standard.
> 
> Additionally I implemented (for those who need and use it) an interface to integrate libdispatch into applications developed using the Qt framework.
> 
> As my port is a bit more than a patch, I named it libxdispatch and it is currently available by going to http://opensource.mlba-team.de/xdispatch - I'm really curious about your comments.
> 
> Regards,
> 
> Marius Zwicker
> 
> 
> 
> _______________________________________________
> libdispatch-dev mailing list
> libdispatch-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev



More information about the libdispatch-dev mailing list