lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [46/49] lucenenet git commit: Ported part of AtomicReferenceArray from Java for testing.
Date Sun, 02 Oct 2016 10:17:17 GMT
Ported part of AtomicReferenceArray from Java for testing.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/44a5cb54
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/44a5cb54
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/44a5cb54

Branch: refs/heads/master
Commit: 44a5cb543394cc9bd2afa42f42d8666c18e66c48
Parents: 979f4e9
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Sep 18 05:22:51 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Sep 18 05:22:51 2016 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Lucene.Net.csproj           |  1 +
 .../Support/AtomicReferenceArray.cs             | 35 ++++++++++++++++++++
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/44a5cb54/src/Lucene.Net.Core/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Lucene.Net.csproj b/src/Lucene.Net.Core/Lucene.Net.csproj
index 4740604..e06e704 100644
--- a/src/Lucene.Net.Core/Lucene.Net.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.csproj
@@ -608,6 +608,7 @@
     <Compile Include="Support\AtomicInteger.cs" />
     <Compile Include="Support\AtomicLong.cs" />
     <Compile Include="Support\AtomicObject.cs" />
+    <Compile Include="Support\AtomicReferenceArray.cs" />
     <Compile Include="Support\Buffer.cs" />
     <Compile Include="Support\AttributeImplItem.cs" />
     <Compile Include="Support\BitSetSupport.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/44a5cb54/src/Lucene.Net.Core/Support/AtomicReferenceArray.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/AtomicReferenceArray.cs b/src/Lucene.Net.Core/Support/AtomicReferenceArray.cs
new file mode 100644
index 0000000..f6f7316
--- /dev/null
+++ b/src/Lucene.Net.Core/Support/AtomicReferenceArray.cs
@@ -0,0 +1,35 @@
+´╗┐using System.Threading;
+
+namespace Lucene.Net.Support
+{
+    /// <summary>
+    /// Mimics Java's AtomicReferenceArray class (partial implementation)
+    /// </summary>
+    /// <typeparam name="T"></typeparam>
+    public class AtomicReferenceArray<T> where T : class
+    {
+        private T[] _array;
+
+        public AtomicReferenceArray(int length)
+        {
+            _array = new T[length];
+        }
+
+        public int Length
+        {
+            get { return _array.Length; }
+        }
+
+        public T this[int index]
+        {
+            get
+            {
+                return Volatile.Read(ref _array[index]);
+            }
+            set
+            {
+                Volatile.Write(ref _array[index], value);
+            }
+        }
+    }
+}


Mime
View raw message