Mercurial > hg > Database > jungle-sharp
changeset 18:faa8a0c1492e
fix Atomic.
author | Kazuma |
---|---|
date | Wed, 09 Nov 2016 22:56:26 +0900 |
parents | 01a08cf4b2d9 |
children | 0865819106cf |
files | src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/transaction/AtomicReference.cs |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/transaction/AtomicReference.cs Mon Nov 07 01:05:24 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/transaction/AtomicReference.cs Wed Nov 09 22:56:26 2016 +0900 @@ -8,9 +8,13 @@ } public bool CompareAndSet(T newValue, T prevValue) { - // change to compere exchange. T oldValue = value; - return (oldValue != Interlocked.CompareExchange (ref value, newValue, prevValue)); + if (oldValue == prevValue) { + Interlocked.CompareExchange (ref value, newValue, prevValue); + return true; + } else { + return false; + } }