I think you should remove `item` from queue first and unlock mutex as early as possible, otherwise other threads will stall while current one is calling `free` and doing various stuff.