コード例 #1
0
 public void Dispose()
 {
     using (_lock.Lock())
     {
         _disposed = true;
         _writer.Dispose();
     }
 }
コード例 #2
0
 internal void Queue(IEventInvocation eventInvocation)
 {
     try
     {
         spinLock.Lock();
         waitingEvents.Enqueue(eventInvocation);
     }
     finally
     {
         spinLock.Unlock();
     }
 }
コード例 #3
0
 public void Recycle()
 {
     Data = default(Data);
     try
     {
         spinLock.Lock();
         pool.Enqueue(this);
     }
     finally
     {
         spinLock.Unlock();
     }
 }
コード例 #4
0
 private static void SpinLockFunc()
 {
     for (int i = 0; i < 100000; i++)
     {
         spinLocker.Lock();
         SpinLockCount++;
         spinLocker.Unlock();
     }
 }
コード例 #5
0
        /// <summary>
        /// Return an item to the pool
        /// </summary>
        /// <param name="item"></param>
        public void Put([NotNull] T item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            using (_putter.Lock())
            {
                _items.TryWrite(item);
            }
        }
コード例 #6
0
 public static byte *ReadLine(byte *output, int length)
 {
     mutex.Lock();
     max      = length;
     position = 0;
     input    = output;
     while (max != -1)
     {
     }
     max      = -1;
     position = 0;
     input    = null;
     mutex.Unlock();
     return(null);
 }
コード例 #7
0
 /// <summary>
 /// Get an item from this pool
 /// </summary>
 /// <returns></returns>
 [NotNull] public T Get()
 {
     using (_getter.Lock())
     {
         T item;
         if (_items.Read(out item) && !ReferenceEquals(item, null))
         {
             return(item);
         }
         else
         {
             return(_factory());
         }
     }
 }