Could Grand Central Dispatch (`libdispatch`) ever be made available on Windows?
I’m looking into multithreading, and GCD seems like a much better option than manually writing a solution using pthread.h
and pthreads-win32
. However, although it looks like libdispatch
is either working on, or soon going to be working on, most newer POSIX-compatible systems… I have to ask, what about Windows? What are the chances of libdispatch
being ported to Windows? What are the barriers preventing that from happening?
If it came down to it, what would I need to do to preform that portage?
Edit: Some things I already know, to get the discussion started:
- We need a blocks-compatible compiler that will compile on Windows, no? Will PLBlocks handle that?
- Can we use the LLVM blocks runtime?
- Can’t we replace all the
pthread.h
dependencies in userspacelibdispatch
with APR calls, for portability? Or, alternatively, usepthreads-win32
I suppose…
Edit 1: I am hearing that this is completely and totally impossible, ever, because libdispatch
depends (somehow) on kqueue
, which can’t be made available on Windows… d开发者_如何学JAVAoes anybody know if this is true?
https://github.com/DrPizza/libdispatch
Take a look at : http://opensource.mlba-team.de/xdispatch/ This project (and other third-party libs) brings libdispatch into platforms(windows, linux) other than macosx
The Windows equivalent of libdispatch, from my basic understanding of it, is the Concurrency Runtime for unmanaged code and a collection of technologies collectively known as Parallel Extensions for managed code. It appears to me that GCD maps pretty well to both of these, since they both abstract work units (or "tasks") in a similar way.
From a bit of research, it appears that there's already a fair bit of interest in a port, but that port would be a fairly drastic undertaking and might end up being basically just another implementation of the API and not actually sharing significant code with the original libdispatch. I did see some proposals to porting libdispatch to being based on the Apache Portable Runtime instead of POSIX which'd make it easier to make it cross-platform to Windows, but even this would not be an easy change.
Likely, this would be by no means a small undertaking.
I think that rather than libdispatch-on-pthreads and pthreads-on-Win32, or libdispatch-on-APR and APR-on-Win32, it might be better to implement libdispatch directly on the Win32 Thread Pool API. The good news is that the two APIs are similar enough that you could probably do the port yourself. The bad news is that there would probably be lots of corner cases where there are small semantic mismatches that make exact behavior hard to achieve.
精彩评论