-
Notifications
You must be signed in to change notification settings - Fork 1
/
QueueManager.cs
40 lines (34 loc) · 1.03 KB
/
QueueManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
namespace ThreadSupport
{
public sealed class QueueManager
{
static readonly QueueManager _instance = new QueueManager();
private readonly Dictionary<String, BlockingQueue<ThreadMessage>> _qList = new Dictionary<String, BlockingQueue<ThreadMessage>>();
private static readonly object syncRoot = new Object();
public static QueueManager Instance
{
get
{
lock (syncRoot) // Make sure we are thread safe
{
return _instance;
}
}
}
public void AddQueue(ref BlockingQueue<ThreadMessage> q, String key)
{
_qList.Add(key, q);
}
public BlockingQueue<ThreadMessage> GetQueue(String key)
{
BlockingQueue<ThreadMessage> result = null;
if (_qList.ContainsKey(key))
{
result = _qList[key];
}
return result;
}
}
}