better-queue
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -249,17 +249,23 @@ var uuid = require('node-uuid'); | ||
self._store.putTask(taskId, task, priority, function (err) { | ||
if (err) { | ||
self._tickets[taskId].failed('failed_to_put_task'); | ||
// Check if task has changed since put | ||
var tickets = self._writing[taskId].tickets; | ||
if (self._writing[taskId].id !== writeId) { | ||
self._writeQueue.unshift(taskId); | ||
return finishedWrite(); | ||
} | ||
delete self._writing[taskId]; | ||
// If something else has written to taskId, then wait. | ||
if (self._writing[taskId].id !== writeId) { | ||
self._writeQueue.unshift(taskId); | ||
if (err) { | ||
tickets.failed('failed_to_put_task'); | ||
return finishedWrite(); | ||
} | ||
delete self._writing[taskId]; | ||
// Task is in the queue | ||
self.length++; | ||
self._tickets[taskId] = tickets; | ||
self.emit('task_queued', taskId, task); | ||
self._tickets[taskId].queued(); | ||
tickets.queued(); | ||
@@ -295,6 +301,4 @@ // If it's a new task, make sure to call drain after. | ||
// Save ticket | ||
if (!self._tickets[taskId]) { | ||
self._tickets[taskId] = new Tickets(); | ||
} | ||
self._tickets[taskId].push(ticket); | ||
var tickets = (self._writing[taskId] && self._writing[taskId].tickets) || new Tickets(); | ||
tickets.push(ticket); | ||
@@ -307,3 +311,4 @@ // Add to queue | ||
task: newTask, | ||
priority: priority | ||
priority: priority, | ||
tickets: tickets | ||
}; | ||
@@ -310,0 +315,0 @@ if (!alreadyQueued) { |
{ | ||
"name": "better-queue", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Better Queue for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "lib/queue.js", |
68076
1772