On Sunday, 9 October 2016 at 20:57:40 UTC, jython234 wrote:
Hello,
I've recently started a project in D, one which I plan to take
advantage of concurrency. This means I will need to use the
shared keyword. However, I have been having a few problems:
1. Where do I use the "shared" keyword? I've done things like
making whole classes shared, which doesn't seem to make the
member methods shared either. Also this creates a million
compiler errors when I try to access the constructor from a
non-shared function.
2. It seems that whenever I use shared I end up doing a ton of
"unsafe" casts from shared, and to shared and it makes me feel
uneasy. I don't think I'm supposed to be doing this.
3. Another concern I have is that I plan on using this project
to introduce other people to D. These people will probably have
some background with programming (such as Java), but will be
new to the "systems" programming area. I like D because of how
broad it can be, but one of the biggest problems it has is the
"shared" issue with Thread local data. This could be hard for
newcomers to learn.
Any tips on how I could fix these problems?
Instead of rewriting a book that already exist I'll just say that
[1] should answer all your questions. However I disagree with
your saying that you'll "have to use shared", D proposes Data
Sharing concurency of course but Message Passing concurrency is
reccomended [2].
[1]: http://ddili.org/ders/d.en/concurrency_shared.html
[2]: http://ddili.org/ders/d.en/concurrency.html