Files
opensim/OpenSim.Framework/BlockingQueue.cs
MW d67b5fa474 Work in progress of adding a embedded java vm for scripting testing /prototyping.
Currently the vm is at a early stage and very limited:
currently only supports static methods (instance methods support is nearly finished though)
currently a class can't have member variables, so currently only local variables in the methods.
Also in this branch, connecting the vm to opensim is not completely finished: it is being uploaded just for viewing purposes.
2007-04-10 15:44:54 +00:00

34 lines
743 B
C#

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();
}
}
}
}