Why is it necessary to use synchronized functions when passing shared variables?

d coder dlang.coder at gmail.com
Sat Mar 5 21:32:03 PST 2011


>
>
> It's probably complaining because using shared without synchronizing is
> generally very foolish. Now, I would have _thought_ that it would still
> work
> without, but I apparently not. Regardless, I'm not sure why you'd want to
> use
> shared anything without synchronizing your access of it.



Thanks Jonathan

Actually in my actual use case, I am using synchronized at code block level
-- to limit the scope of locking. I am doing this to mitigate possible
inefficiency due to indiscriminate use of mutex locked code.

But D is forcing me to synchronize at function level, thus making most of my
code go under mutex locks.

Regards
- Puneet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110306/85fda917/attachment.html>


More information about the Digitalmars-d-learn mailing list