Re: How to use core.thread.Thread

2015-07-17 Thread byron via Digitalmars-d-learn
On Friday, 17 July 2015 at 07:56:48 UTC, aki wrote: On Thursday, 16 July 2015 at 09:17:47 UTC, Daniel Kozák wrote: class DerivedThread : Thread { shared int count = 0; } I thought shared is only for whole of the object. auto thr = new DerivedThread(); Here, thr is not shared but it's

Re: How to use core.thread.Thread

2015-07-17 Thread aki via Digitalmars-d-learn
On Thursday, 16 July 2015 at 09:17:47 UTC, Daniel Kozák wrote: class DerivedThread : Thread { shared int count = 0; } I thought shared is only for whole of the object. auto thr = new DerivedThread(); Here, thr is not shared but it's member thr.count is shared? But if it's not shared,

Re: How to use core.thread.Thread

2015-07-17 Thread aki via Digitalmars-d-learn
On Friday, 17 July 2015 at 14:14:41 UTC, byron wrote: Since I have yet to use or see anyone use shared in a useful way I avoid it. It's one way to avoid it. So, you mean you always use send/receive when you need threading? I did small test to know the memory layout. import core.atomic; int

Re: How to use core.thread.Thread

2015-07-16 Thread maarten van damme via Digitalmars-d-learn
You can certainly use thread but in most use cases, concurrency or parallelism will accomplish the same in a much saner/safer way. (they're wrappers around core.thread anyway). Don't know of any tutorials about core.thread, about the other two you can find help here : http://ddili.org/ders/d.en/

Re: How to use core.thread.Thread

2015-07-16 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 16 Jul 2015 07:57:10 + aki via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I can't resolve the compile errors: import core.thread; class DerivedThread : Thread { int count = 0; this() { super(run); } private void run()

Re: How to use core.thread.Thread

2015-07-16 Thread aki via Digitalmars-d-learn
On Thursday, 16 July 2015 at 08:21:26 UTC, maarten van damme wrote: Have you checked out std.parallelism and std.concurrency? I know std.concurrency to use spawn. If I cannot use Thread, I'll implement by spawn. But want to try Thread class because it seems similar to Java's Thread class. I

How to use core.thread.Thread

2015-07-16 Thread aki via Digitalmars-d-learn
I can't resolve the compile errors: import core.thread; class DerivedThread : Thread { int count = 0; this() { super(run); } private void run() { inc(); //testThread.d(8): Error: shared method testThread.DerivedThread.inc is not callable using a

Re: How to use core.thread.Thread

2015-07-16 Thread maarten van damme via Digitalmars-d-learn
Have you checked out std.parallelism and std.concurrency? 2015-07-16 9:57 GMT+02:00 aki via Digitalmars-d-learn digitalmars-d-learn@puremagic.com: I can't resolve the compile errors: import core.thread; class DerivedThread : Thread { int count = 0; this() {

Re: How to use core.thread.Thread

2015-07-16 Thread byron via Digitalmars-d-learn
On Thursday, 16 July 2015 at 21:48:06 UTC, byron wrote: On Thursday, 16 July 2015 at 07:57:13 UTC, aki wrote: [...] If I remember a synchronized method requires this to be shared, you should be fine using a synchronized block in the method for non-shared instances. But using atomicOp

Re: How to use core.thread.Thread

2015-07-16 Thread byron via Digitalmars-d-learn
On Thursday, 16 July 2015 at 07:57:13 UTC, aki wrote: I can't resolve the compile errors: import core.thread; class DerivedThread : Thread { int count = 0; this() { super(run); } private void run() { inc(); //testThread.d(8): Error: shared