removing resourcet.
Using atomicModifyIORef' to ensure to use a good pattern.

See P284 of the ParCon book in detail.