Re: how does 'shared' affect member variables?

2015-05-09 Thread bitwise via Digitalmars-d-learn
On Sat, 09 May 2015 21:32:42 -0400, Mike n...@none.com wrote: it looks like what you are trying to implement is what `synchronized` already provides: http://ddili.org/ders/d.en/concurrency_shared.html#ix_concurrency_shared.synchronized Mike Yes, but synchronized uses a mutex. Spin locks

Re: how does 'shared' affect member variables?

2015-05-09 Thread bitwise via Digitalmars-d-learn
On Sat, 09 May 2015 15:38:05 -0400, Mike n...@none.com wrote: On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: Also, I wasn't able to find any thorough documentation on shared, so if someone has a link, that would be helpful. Here are a few interesting links: Iain Buclaw (lead

Re: how does 'shared' affect member variables?

2015-05-09 Thread anonymous via Digitalmars-d-learn
On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: What does 'shared' do to member variables? Makes them `shared`. :P It makes sense to me to put it on a global variable, but what sense does it make putting it on a member of a class? Globals are not the only way to pass data to other

Re: how does 'shared' affect member variables?

2015-05-09 Thread anonymous via Digitalmars-d-learn
On Saturday, 9 May 2015 at 19:59:58 UTC, tcak wrote: Stupidly, shared variables' value cannot be increased/decreased directly. Compiler says it is deprecated, and tells me to use core.atomic.atomicop. You will see this as well. How's that stupid? Sounds like the compiler is doing its job

Re: how does 'shared' affect member variables?

2015-05-09 Thread bitwise via Digitalmars-d-learn
On Sat, 09 May 2015 15:59:57 -0400, tcak t...@gmail.com wrote: If a variable/class/struct etc is not shared, for variables and struct, you find their initial value. For class, you get null. For first timers (I started using shared keyword more than 2 years ago), do not forget that: a shared

Re: how does 'shared' affect member variables?

2015-05-09 Thread Mike via Digitalmars-d-learn
On Saturday, 9 May 2015 at 20:17:59 UTC, bitwise wrote: On Sat, 09 May 2015 15:38:05 -0400, Mike n...@none.com wrote: On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: Also, I wasn't able to find any thorough documentation on shared, so if someone has a link, that would be helpful.

how does 'shared' affect member variables?

2015-05-09 Thread bitwise via Digitalmars-d-learn
What does 'shared' do to member variables? It makes sense to me to put it on a global variable, but what sense does it make putting it on a member of a class? What happens if you try to access a member of a class/struct instance from another thread that is not marked 'shared'? Also, I

Re: how does 'shared' affect member variables?

2015-05-09 Thread Mike via Digitalmars-d-learn
On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: Also, I wasn't able to find any thorough documentation on shared, so if someone has a link, that would be helpful. Here are a few interesting links: Iain Buclaw (lead developer for GDC) with his interpretation:

Re: how does 'shared' affect member variables?

2015-05-09 Thread tcak via Digitalmars-d-learn
On Saturday, 9 May 2015 at 18:41:59 UTC, bitwise wrote: What does 'shared' do to member variables? It makes sense to me to put it on a global variable, but what sense does it make putting it on a member of a class? What happens if you try to access a member of a class/struct instance from