yesod::counted_ptr: overhaul of implementation to enable partial atomicity (2)

Also, implement correct stateful allocator support.

Signed-off-by: Alex Dubov <oakad@yahoo.com>