prevent task state change from overriding task cancel

task states of snooze and running must not override task cancel
otherwise it can cause a hang while shutting down bucket
use atomic compare and swap for safe lockless operation.

Change-Id: Ibfc3c7745d0c40893c577d3d94775f523ecc2861
Reviewed-on: http://review.couchbase.org/40060
Tested-by: Sundararaman Sridharan <sundar@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>