Esempio n. 1
0
 public void Dispose()
 {
     using (_lock.Lock())
     {
         _disposed = true;
         _writer.Dispose();
     }
 }
Esempio n. 2
0
 internal void Queue(IEventInvocation eventInvocation)
 {
     try
     {
         spinLock.Lock();
         waitingEvents.Enqueue(eventInvocation);
     }
     finally
     {
         spinLock.Unlock();
     }
 }
Esempio n. 3
0
 public void Recycle()
 {
     Data = default(Data);
     try
     {
         spinLock.Lock();
         pool.Enqueue(this);
     }
     finally
     {
         spinLock.Unlock();
     }
 }
Esempio n. 4
0
 private static void SpinLockFunc()
 {
     for (int i = 0; i < 100000; i++)
     {
         spinLocker.Lock();
         SpinLockCount++;
         spinLocker.Unlock();
     }
 }
        /// <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);
            }
        }
Esempio n. 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);
 }
 /// <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());
         }
     }
 }