Fix race between slice writer commit and insert

Before doing insert its not sufficient to check if the command
channel is empty. The last command might still be getting processed.
Wait till the workers have finished processing all commands, before commit.

Patchset:
More robust channel based mechanism. Previous logic had
race conditions.

Change-Id: Iad86b827adf5240a8cebd99c0e278232f509f4cd
Reviewed-on: http://review.couchbase.org/39599
Reviewed-by: John Liang <johliang00@gmail.com>
Reviewed-by: Deepkaran Salooja <deepkaran.couchbase@gmail.com>
Tested-by: Deepkaran Salooja <deepkaran.couchbase@gmail.com>