public void Dispose() { using (_lock.Lock()) { _disposed = true; _writer.Dispose(); } }
internal void Queue(IEventInvocation eventInvocation) { try { spinLock.Lock(); waitingEvents.Enqueue(eventInvocation); } finally { spinLock.Unlock(); } }
public void Recycle() { Data = default(Data); try { spinLock.Lock(); pool.Enqueue(this); } finally { spinLock.Unlock(); } }
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); } }
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()); } } }