Re: Threading Questions

2015-10-09 Thread Kagamin via Digitalmars-d-learn
On Friday, 9 October 2015 at 04:04:42 UTC, bitwise wrote: Ah, I see. I thought you meant illegal meant it won't compile. Wouldn't it be more correct to say that it's undefined behaviour? I's probably not as undefined as in C case, i.e. it doesn't break safety guarantees, only the application'

Re: Threading Questions

2015-10-08 Thread bitwise via Digitalmars-d-learn
On Thursday, 8 October 2015 at 20:42:46 UTC, Kagamin wrote: On Thursday, 8 October 2015 at 13:44:46 UTC, bitwise wrote: That still doesn't explain what you mean about it being illegal in other languages or why you brought up C# in the first place. Illegal means the resulting program behaves i

Re: Threading Questions

2015-10-08 Thread Kagamin via Digitalmars-d-learn
On Thursday, 8 October 2015 at 13:44:46 UTC, bitwise wrote: That still doesn't explain what you mean about it being illegal in other languages or why you brought up C# in the first place. Illegal means the resulting program behaves incorrectly, potentially leading to silent failures and data c

Re: Threading Questions

2015-10-08 Thread bitwise via Digitalmars-d-learn
On Thursday, 8 October 2015 at 10:11:38 UTC, Kagamin wrote: On Thursday, 8 October 2015 at 02:31:24 UTC, bitwise wrote: If you have System.Collections.Generic.List(T) static class member, there is nothing wrong with using it from multiple threads like this: The equivalent of your D example wo

Re: Threading Questions

2015-10-08 Thread Kagamin via Digitalmars-d-learn
On Thursday, 8 October 2015 at 02:31:24 UTC, bitwise wrote: If you have System.Collections.Generic.List(T) static class member, there is nothing wrong with using it from multiple threads like this: The equivalent of your D example would be class Foo { static List numbers = new List();

Re: Threading Questions

2015-10-07 Thread bitwise via Digitalmars-d-learn
On Wednesday, 7 October 2015 at 09:09:36 UTC, Kagamin wrote: On Sunday, 4 October 2015 at 04:24:55 UTC, bitwise wrote: I use C#(garbage collected) for making apps/games, and while, _in_theory_, the GC is supposed to protect you from leaks, memory is not the only thing that can leak. Threads nee

Re: Threading Questions

2015-10-07 Thread Kagamin via Digitalmars-d-learn
On Sunday, 4 October 2015 at 04:24:55 UTC, bitwise wrote: I use C#(garbage collected) for making apps/games, and while, _in_theory_, the GC is supposed to protect you from leaks, memory is not the only thing that can leak. Threads need to be stopped, graphics resources need to be released, etc.

Re: Threading Questions

2015-10-05 Thread bitwise via Digitalmars-d-learn
On Monday, 5 October 2015 at 20:18:18 UTC, Laeeth Isharc wrote: On Monday, 5 October 2015 at 17:40:24 UTC, bitwise wrote: You may be right. I wrote a simple download manager in D using message passing. It was a little awkward at first, but in general, the spawn/send/receive API seems very intui

Re: Threading Questions

2015-10-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/5/15 1:40 PM, bitwise wrote: On Monday, 5 October 2015 at 00:23:21 UTC, Jonathan M Davis wrote: On Sunday, October 04, 2015 14:42:48 bitwise via Digitalmars-d-learn wrote: Since D is moving towards a phobos with no GC, what will happen to things that are classes like Condition and Mutex?

Re: Threading Questions

2015-10-05 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 5 October 2015 at 17:40:24 UTC, bitwise wrote: You may be right. I wrote a simple download manager in D using message passing. It was a little awkward at first, but in general, the spawn/send/receive API seems very intuitive. It feels awkward because the data you're working with is o

Re: Threading Questions

2015-10-05 Thread bitwise via Digitalmars-d-learn
On Monday, 5 October 2015 at 00:23:21 UTC, Jonathan M Davis wrote: On Sunday, October 04, 2015 14:42:48 bitwise via Digitalmars-d-learn wrote: Since D is moving towards a phobos with no GC, what will happen to things that are classes like Condition and Mutex? Phobos and druntime will always us

Re: Threading Questions

2015-10-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 04, 2015 14:42:48 bitwise via Digitalmars-d-learn wrote: > Since D is moving towards a phobos with no GC, what will happen > to things that are classes like Condition and Mutex? Phobos and druntime will always use the GC for some things, and some things just plain need classes.

Re: Threading Questions

2015-10-04 Thread bitwise via Digitalmars-d-learn
On Wednesday, 30 September 2015 at 10:32:01 UTC, Jonathan M Davis wrote: On Tuesday, September 29, 2015 22:38:42 Johannes Pfau via Digitalmars-d-learn wrote: [...] What I took from the answers to that SO question was that in general, it really doesn't matter whether a condition variable has

Re: Threading Questions

2015-10-04 Thread bitwise via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 23:20:31 UTC, Steven Schveighoffer wrote: yeah, that could probably be done. One thing to note is that these classes are from ages ago (probably close to 10 years). New API suggestions may be allowed. -Steve I'm still thinking about my last rant, here... S

Re: Threading Questions

2015-10-03 Thread bitwise via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 19:10:58 UTC, Steven Schveighoffer wrote: An object that implements the Monitor interface may not actually be a mutex. For example, a pthread_cond_t requires a pthread_mutex_t to operate properly. Right! I feel like I should have caught the fact that Conditi

Re: Threading Questions

2015-10-01 Thread Kagamin via Digitalmars-d-learn
On Friday, 25 September 2015 at 15:19:27 UTC, bitwise wrote: I know that all global variables are TLS unless explicitly marked as 'shared', but someone once told me something about 'shared' affecting member variables in that accessing them from a separate thread would return T.init instead of t

Re: Threading Questions

2015-09-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 29, 2015 22:38:42 Johannes Pfau via Digitalmars-d-learn wrote: > Am Tue, 29 Sep 2015 15:10:58 -0400 > schrieb Steven Schveighoffer : > > > > > > 3) Why do I have to pass a "Mutex" to "Condition"? Why can't I just > > > pass an "Object"? > > > > An object that implements the M

Re: Threading Questions

2015-09-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/29/15 4:38 PM, Johannes Pfau wrote: Am Tue, 29 Sep 2015 15:10:58 -0400 schrieb Steven Schveighoffer : 3) Why do I have to pass a "Mutex" to "Condition"? Why can't I just pass an "Object"? An object that implements the Monitor interface may not actually be a mutex. For example, a pthrea

Re: Threading Questions

2015-09-29 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 29 Sep 2015 15:10:58 -0400 schrieb Steven Schveighoffer : > > > 3) Why do I have to pass a "Mutex" to "Condition"? Why can't I just > > pass an "Object"? > > An object that implements the Monitor interface may not actually be a > mutex. For example, a pthread_cond_t requires a pthread_m

Re: Threading Questions

2015-09-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/25/15 11:19 AM, bitwise wrote: Hey, I've got a few questions if anybody's got a minute. I'm trying to wrap my head around the threading situation in D. So far, things seem to be working as expected, but I want to verify my solutions. 1) Are the following two snippets exactly equivalent(not

Re: Threading Questions

2015-09-29 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2015-09-29 at 03:05 +, bitwise via Digitalmars-d-learn wrote: > On Monday, 28 September 2015 at 11:47:38 UTC, Russel Winder wrote: > > I hadn't answered as I do not have answers to the questions you > > ask. My reason: people should not be doing their codes using > > these low-level s

Re: Threading Questions

2015-09-28 Thread bitwise via Digitalmars-d-learn
On Monday, 28 September 2015 at 11:47:38 UTC, Russel Winder wrote: I hadn't answered as I do not have answers to the questions you ask. My reason: people should not be doing their codes using these low-level shared memory techniques. Data parallel things should be using the std.parallelism modu

Re: Threading Questions

2015-09-28 Thread Russel Winder via Digitalmars-d-learn
I hadn't answered as I do not have answers to the questions you ask. My reason: people should not be doing their codes using these low-level shared memory techniques. Data parallel things should be using the std.parallelism module. Dataflow-style things should be using spawn and channels – akin to

Re: Threading Questions

2015-09-26 Thread ponce via Digitalmars-d-learn
Sorry I don't know the answers but these questions are interesting so BUMP ;) On Friday, 25 September 2015 at 15:19:27 UTC, bitwise wrote: 1) Are the following two snippets exactly equivalent(not just in observable behaviour)? a) Mutex mut; mut.lock(); scope(exit) mut.unlock(); b) Mutex mu

Re: Threading Questions

2015-09-25 Thread bitwise via Digitalmars-d-learn
Pretty please? :)