Armin said:
Hi,
is there a documentation out there that tells me which operations are atomic?
Depends on what you mean. The C# specification, for example, is clear
about what operations within the language are atomic (certain
assignments and reads, specifically).
But of course it doesn't mention any of the System.Threading.Interlocked
class, for example, which also provides for certain atomic operations.
In that sense, no...there's not a single place that all atomic
operations are documented.
I currently have to know if increasing a System.Decimal value is an atomic operation.
An increment of any value is not guaranteed to be atomic unless you use
the Interlocked class, and the System.Decimal type is too wide to be
supported by the Interlocked class in any case.
I guess it is not. The value is increased in one thread and read from another thread. I think I have to use a
lock. Right?
You have to use some kind of synchronization, yes. And because it's so
wide, the System.Decimal type isn't even among those in C# that even has
atomic assignment.
There are a wide variety of possibilities, but a "lock" statement is
definitely the way to go, until you have some reason to believe you need
something cleverer and more efficient.
Pete