5 ms·
Does anyone use Apple’s libdispatch (aka GCD) on Linux production code? It seems to be pretty fast and has some neat features. It also gives you blocks/closure
by innagadadavida 7y ago
Does anyone use Apple’s libdispatch (aka GCD) on Linux production code? It seems to be pretty fast and has some neat features. It also gives you blocks/closure support in C (needs Clang).
- deleted 7y ago[deleted]
- gigatexal 7y ago+1 to this question I too am curious
- shakna 7y ago> It also gives you blocks/closure support in C (needs Clang). You get block statements just with Clang don't you? No need for libdispatch? And you can kinda get blocks with GCC as well using a similar construct. (For the love of all that is holy, don't actually use this macro). #define lambda(ret_type, _body) ({ ret_type _ _body _; }) I don't quite remember, but from when I was working things out, this worked _most_ of the time for both GCC and clang.
- Yoric 7y agoOh, libdispatch has been ported to other platforms? That's great!
- innagadadavida 7y agoWas available in FreeBSD back in 2009: https://wiki.freebsd.org/GCD https://wiki.freebsd.org/GCD Archived Linux port: https://github.com/nickhutchinson/libdispatch https://github.com/nickhutchinson/libdispatch You can use this without blocks, but it is way more convenient with blocks.
- Yoric 7y agoGood to know, thanks!
- Matthias247 7y agoIf you are open to C++ [boost] asio is pretty close and is cross platform. Running an io_service on a thread gives you something that resembles a dispatch_queue. And instead of blocks you can post C++ closures to the queues.