Work on threads based on having a better understanding of threading (i.e
using semaphores and atomic operations)

I worked on the thread pool and promises changing things that used
mutexes and condititon variables to use semaphores, and in the case of
promises rw locks.

I also added two thread related files, atomic.h with some macros for
atomic operations and priority_queue.c with a priority queue
implementation to use in the thread pool