Guo Hui 6 år sedan
förälder
incheckning
ada09e8f9d
2 ändrade filer med 36 tillägg och 0 borttagningar
  1. 1 0
      src/Chino.Core/Chino.Core.csproj
  2. 35 0
      src/Chino.Core/Collections/ConcurrentSList.cs

+ 1 - 0
src/Chino.Core/Chino.Core.csproj

@@ -4,6 +4,7 @@
     <TargetFramework>netcoreapp3.0</TargetFramework>
     <OutputPath>$(SolutionDir)out/bin/</OutputPath>
     <RootNamespace>Chino</RootNamespace>
+    <Nullable>Enable</Nullable>
   </PropertyGroup>
 
 </Project>

+ 35 - 0
src/Chino.Core/Collections/ConcurrentSList.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Chino.Collections
+{
+    public class SListEntry
+    {
+        internal SListEntry _next;
+    }
+
+    public class ConcurrentSList
+    {
+        private volatile SListEntry? _head;
+        private volatile SListEntry? _tail;
+
+        public bool IsEmpty => _head == null;
+
+        public int Count
+        {
+            get
+            {
+                int count = 0;
+                for (SListEntry? cnt = _head; cnt != null; cnt = cnt._next)
+                    count++;
+                return count;
+            }
+        }
+
+        public void Clear()
+        {
+            _head = null;
+        }
+    }
+}