digitalmars.D - Safe std.parallelism
- dsimcha (21/21) Sep 15 2010 As I've mentioned before, my std.parallelism module (formerly parallelfu...
- Simen kjaeraas (6/19) Sep 15 2010 Of these, #1 breaks with the D tradition (or stated such, anyway) of
As I've mentioned before, my std.parallelism module (formerly parallelfuture; http://cis.jhu.edu/~dsimcha/d/phobos/std_parallelism.html, http://dsource.org/projects/scrapple/browser/trunk/parallelFuture/std_parallelism.d) is currently in review for inclusion in Phobos. Originally I thought that, for a pedal-to-metal parallelism library, any safe construct would be too limited to be useful to anyone. Based on some discussions on this NG and the Phobos mailing list I'm starting to change my mind. I think std.parallelism should still allow, and even be primarily geared towards pedal-to-metal parallelism, but I think map(), reduce() and Task could be made safe under some limited but useful circumstances. I'd like to bounce a design question off the community. Given the current design of std.parallelism, I see three ways of adding the safe functionality. 1. Create safeTask(), safeMap(), safeReduce() that only accept safe arguments. This is ugly but explicit. Suggestions for better names would be appreciated. 2. Just overload task(), map() and reduce() so that the overload marked trusted can be used in SafeD and is as safe as std.concurrency, and the unsafe version can be called from system code. 3. Name the safe versions task(), map() and reduce() and rename the unsafe versions something else. (I kind of don't like this because std.parallelism, by its nature, is mostly geared towards unsafe, pedal-to-metal parallelism.)
Sep 15 2010
dsimcha <dsimcha yahoo.com> wrote:2. Just overload task(), map() and reduce() so that the overload marked trusted can be used in SafeD and is as safe as std.concurrency, and the unsafe version can be called from system code.This seems to me the best solution.1. Create safeTask(), safeMap(), safeReduce() that only accept safe arguments. This is ugly but explicit. Suggestions for better names would be appreciated.3. Name the safe versions task(), map() and reduce() and rename the unsafe versions something else. (I kind of don't like this because std.parallelism, by its nature, is mostly geared towards unsafe, pedal-to-metal parallelism.)safe being the default. -- Simen
Sep 15 2010