2016-08-27

Grand Central Dispatch for Android?

(Sometimes after a couple of hours of research, the result is a dead-end or needs further digesting.
Still, such a result might itself still be worth remembering.
This is a Quick&Dirty report of one of those cases.)

GCD is an implementation of thread pools / queueing (+ event management (sockets, files), etc) by Apple for Mac OS X / iOS. It was open-sourced, and FreeBSD got an implementation. They are practically an abstraction and simplification over pthreads (+ events, etc), and the GCD implementation includes some kernel and compiler changes (workqueues and blocks, respectively). Implementation details at http://newosxbook.com/articles/GCD.html. It's well performing and seemingly can help simplifying a lot.

What if one wanted to use GCD in Android? Is there anything compatible enough and that could be used at the C level?

Assuming that Android is a Linux ;P, then we can start with the fact that Linux doesn't seem to have any official GCD-like thingie. However, there are a couple of GCD ports, which do not seem to use anything kernel-level, and only optionally take advantage of compiler support for blocks- which anyway should be available in Clang, maybe even in GCC.
https://github.com/nickhutchinson/libdispatch
https://github.com/mlba-team/xdispatch (even for Windows!)


No comments

Post a Comment