Kinvey/node-background-task — pull request #3 by vseventer (2013-08-22 16:15:03+00:00)
Title: Publish only once when sending multiple responses concurrently.

With the addition of progress events, data will be `hset` on the same `msgId` multiple times.

If two events are submitted concurrently, `hset` will be called twice, but because of the asynchrony, both `hset`s will complete before it is published. Thus, publish is called twice, while there was really only one update (the second `hset`).

This commit makes sure publish is only called when the last concurrent `hset` completes. Given redis processes commands in order [1], this works well.

[1] http://stackoverflow.com/a/12344714