changeset 234:8dd666e6b6bf v2

Added implab nuget spec
author cin
date Thu, 05 Oct 2017 09:21:23 +0300
parents d6fe09f5592c
children b49969a7043c
files Implab.Playground/Program.cs Implab/Implab.csproj Implab/Implab.nuspec Implab/Parallels/AsyncQueue.cs Implab/Properties/AssemblyInfo.cs Implab/implab.snk Implab/license.txt
diffstat 7 files changed, 78 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/Implab.Playground/Program.cs	Wed Oct 04 15:44:47 2017 +0300
+++ b/Implab.Playground/Program.cs	Thu Oct 05 09:21:23 2017 +0300
@@ -49,7 +49,6 @@
             return actual != 0;
         }
 
-        /*
         static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
             for (var i = offset; i < offset + len; i++)
                 q.Enqueue(data[i]);
@@ -66,15 +65,15 @@
             }
             return actual != 0;
         }
-        */
+        
         
-        static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
+        /*static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
             q.EnqueueRange(data, offset, len);
         }
 
         static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
             return q.TryDequeueRange(buffer, offset, len, out actual);
-        }
+        }*/
         
 
         static void Main(string[] args) {
--- a/Implab/Implab.csproj	Wed Oct 04 15:44:47 2017 +0300
+++ b/Implab/Implab.csproj	Thu Oct 05 09:21:23 2017 +0300
@@ -67,6 +67,12 @@
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
   </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>implab.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Xml" />
@@ -207,7 +213,12 @@
     <Compile Include="Xml\XmlNameContext.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-  <ItemGroup />
+  <ItemGroup>
+    <None Include="Implab.nuspec">
+      <SubType>Designer</SubType>
+    </None>
+    <None Include="implab.snk" />
+  </ItemGroup>
   <ProjectExtensions>
     <MonoDevelop>
       <Properties>
@@ -279,5 +290,7 @@
       </Properties>
     </MonoDevelop>
   </ProjectExtensions>
-  <ItemGroup />
+  <ItemGroup>
+    <Content Include="license.txt" />
+  </ItemGroup>
 </Project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Implab/Implab.nuspec	Thu Oct 05 09:21:23 2017 +0300
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>Implab</id>
+    <version>$version$</version>
+    <title>$title$</title>
+    <authors>Implab team</authors>
+    <owners>Implab team</owners>
+    <projectUrl>https://implab.org/</projectUrl>
+    <!-- <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl> -->
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <description>Common components for asynchronous applications, tracing, logging, json and xml traits.</description>
+    <releaseNotes>Added strong name.</releaseNotes>
+    <copyright>Copyright 2017</copyright>
+    <tags>async xml json</tags>
+  </metadata>
+</package>
\ No newline at end of file
--- a/Implab/Parallels/AsyncQueue.cs	Wed Oct 04 15:44:47 2017 +0300
+++ b/Implab/Parallels/AsyncQueue.cs	Thu Oct 05 09:21:23 2017 +0300
@@ -3,6 +3,7 @@
 using System;
 using System.Collections;
 using System.Diagnostics;
+using System.Runtime.CompilerServices;
 
 namespace Implab.Parallels {
     public class AsyncQueue<T> : IEnumerable<T> {
@@ -51,6 +52,16 @@
                 get { return m_size; }
             }
 
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            void AwaitWrites(int mark) {
+                if (m_hi != mark) {
+                    SpinWait spin = new SpinWait();
+                    do {
+                        spin.SpinOnce();
+                    } while (m_hi != mark);
+                }
+            }
+
             public bool TryEnqueue(T value) {
                 int alloc;
                 do {
@@ -61,12 +72,7 @@
                 
                 m_data[alloc] = value;
 
-                SpinWait spin = new SpinWait();
-                // m_hi is volatile
-                while (alloc != m_hi) {
-                    // spin wait for commit
-                    spin.SpinOnce();
-                }
+                AwaitWrites(alloc);
                 m_hi = alloc + 1;
 
                 return true;
@@ -77,10 +83,7 @@
             /// </summary>
             public void Seal() {
                 var actual = Math.Min(Interlocked.Exchange(ref m_alloc, m_size), m_size);
-                SpinWait spin = new SpinWait();
-                while (m_hi != actual) {
-                    spin.SpinOnce();
-                }
+                AwaitWrites(actual);
             }
 
             public bool TryDequeue(out T value, out bool recycle) {
@@ -114,11 +117,7 @@
                 
                 Array.Copy(batch, offset, m_data, alloc, enqueued);
 
-                SpinWait spin = new SpinWait();
-                while (alloc != m_hi) {
-                    spin.SpinOnce();
-                }
-
+                AwaitWrites(alloc);
                 m_hi = alloc + enqueued;
                 return true;
             }
@@ -361,9 +360,7 @@
         }
 
         public List<T> Drain() {
-            // start the new queue
-            var chunk = new Chunk(DEFAULT_CHUNK_SIZE);
-
+            Chunk chunk = null;
             do {
                 var first = m_first;
                 // first.next is volatile
@@ -374,6 +371,10 @@
                         return new List<T>();
                 }
 
+                // start the new queue
+                if (chunk == null)
+                    chunk = new Chunk(DEFAULT_CHUNK_SIZE);
+
                 // here we will create inconsistency which will force others to spin
                 // and prevent from fetching. chunk.next = null
                 if (first != Interlocked.CompareExchange(ref m_first, chunk, first))
--- a/Implab/Properties/AssemblyInfo.cs	Wed Oct 04 15:44:47 2017 +0300
+++ b/Implab/Properties/AssemblyInfo.cs	Thu Oct 05 09:21:23 2017 +0300
@@ -1,5 +1,4 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // Information about this assembly is defined by the following attributes. 
@@ -7,11 +6,9 @@
 
 [assembly: AssemblyTitle("Implab")]
 [assembly: AssemblyDescription("Tools")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("")]
+[assembly: AssemblyCompany("Implab.org")]
 [assembly: AssemblyCopyright("Implab")]
-[assembly: AssemblyTrademark("")]
+[assembly: AssemblyTrademark("Implab")]
 // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
 // The form "{Major}.{Minor}.*" will automatically update the build and revision,
 // and "{Major}.{Minor}.{Build}.*" will update just the revision.
Binary file Implab/implab.snk has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Implab/license.txt	Thu Oct 05 09:21:23 2017 +0300
@@ -0,0 +1,22 @@
+Copyright 2012 Sergey Smirnov
+
+Redistribution and use in source and binary forms, with or without 
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, 
+this list of conditions and the following disclaimer in the documentation 
+and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file