Some checks failed
Build and Deploy on Tag / build-crosslang-shell-and-cpkg (push) Failing after 26s
65 lines
977 B
Plaintext
65 lines
977 B
Plaintext
class ConcurrentQueue
|
|
{
|
|
private mtx = new Mutex();
|
|
|
|
private queue = new Queue();
|
|
|
|
public Enqueue(val)
|
|
{
|
|
mtx.Lock();
|
|
queue.Enqueue(val);
|
|
mtx.Unlock();
|
|
|
|
}
|
|
|
|
public Dequeue()
|
|
{
|
|
mtx.Lock();
|
|
const val = queue.Dequeue();
|
|
mtx.Unlock();
|
|
|
|
return val;
|
|
}
|
|
public Peek()
|
|
{
|
|
mtx.Lock();
|
|
const val = queue.Peek();
|
|
mtx.Unlock();
|
|
|
|
return val;
|
|
}
|
|
|
|
public getCount()
|
|
{
|
|
mtx.Lock();
|
|
const val = queue.Count;
|
|
mtx.Unlock();
|
|
|
|
return val;
|
|
}
|
|
public getLength()
|
|
{
|
|
mtx.Lock();
|
|
const val = queue.Length;
|
|
mtx.Unlock();
|
|
|
|
return val;
|
|
}
|
|
|
|
public ToList()
|
|
{
|
|
|
|
mtx.Lock();
|
|
|
|
const ittr = new Queryable(queue);
|
|
const ls = ittr.ToList();
|
|
|
|
mtx.Unlock();
|
|
return ls;
|
|
}
|
|
|
|
public GetEnumerator()
|
|
{
|
|
return ToList().GetEnumerator();
|
|
}
|
|
} |