private QueueWorker EnsureWorkerPool(string queue) { QueueWorker worker; if (!_workerPool.TryGetValue(queue, out worker)) { lock (_workerPool) { if (!_workerPool.TryGetValue(queue, out worker)) { worker = new QueueWorker(queue); QueueWorker parent = worker; for (var i = 0; i < _defaultWorkersPerQueue; i++) { parent.Next = new QueueWorker(queue); parent = parent.Next; } parent.Next = worker; worker = _workerPool.GetOrAdd(queue, worker); } } } return(worker); }
private void AssignWork(QueueWorker worker) { var root = worker; var selectedWorker = worker; var db = _connectionMultiplexer.GetDatabase(); string value = db.ListRightPopLeftPush(selectedWorker.Queue, selectedWorker.WorkQueue); if (value != null) // moved message to worker queue { worker.DoWork(); } }