mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 01:35:46 +08:00
Renamed the new Directories. (removed the "-Source" from the end of them)
This commit is contained in:
33
Common/OpenSim.Framework/BlockingQueue.cs
Normal file
33
Common/OpenSim.Framework/BlockingQueue.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Utilities
|
||||
{
|
||||
public class BlockingQueue<T>
|
||||
{
|
||||
private Queue<T> _queue = new Queue<T>();
|
||||
private object _queueSync = new object();
|
||||
|
||||
public void Enqueue(T value)
|
||||
{
|
||||
lock (_queueSync)
|
||||
{
|
||||
_queue.Enqueue(value);
|
||||
Monitor.Pulse(_queueSync);
|
||||
}
|
||||
}
|
||||
|
||||
public T Dequeue()
|
||||
{
|
||||
lock (_queueSync)
|
||||
{
|
||||
if (_queue.Count < 1)
|
||||
Monitor.Wait(_queueSync);
|
||||
|
||||
return _queue.Dequeue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user