diff src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/transaction/AtomicReference.cs @ 10:abe0c247f5a5

Add Network module. but, unComplete NetworkDefaultJungleTreeEditor.cs
author Kazuma Takeda <kazuma-arashi@hotmail.co.jp>
date Sun, 23 Oct 2016 07:40:50 +0900
parents
children faa8a0c1492e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/transaction/AtomicReference.cs	Sun Oct 23 07:40:50 2016 +0900
@@ -0,0 +1,20 @@
+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;
+	}
+}