added Semaphore, and changed with-barrier macro to make lib more user
friendly