Mercurial > hg > Database > jungle-sharp
view src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/transaction/AtomicReference.cs @ 17:01a08cf4b2d9
Liq Files
author | Kazuma |
---|---|
date | Mon, 07 Nov 2016 01:05:24 +0900 |
parents | abe0c247f5a5 |
children | faa8a0c1492e |
line wrap: on
line source
using System.Threading; public class AtomicReference <T> where T : class { private T value; public AtomicReference(T value) { this.value = value; } public bool CompareAndSet(T newValue, T prevValue) { // change to compere exchange. T oldValue = value; return (oldValue != Interlocked.CompareExchange (ref value, newValue, prevValue)); } public T Get() { return value; } }