Soul-Engine icon indicating copy to clipboard operation
Soul-Engine copied to clipboard

Create Spinlock Class

Open Behemyth opened this issue 7 years ago • 0 comments

If you look in Soul Engine\Source\Parallelism\Fiber\SchedulerAlgorithm.h you will find on line 57 boost::fibers::detail::spinlock. Essentially, when many threads try to access the localQueues_ the spin-lock only allows one thread at a time. If you used a mutex like std::mutex the thread might give control to another thread. This is really bad as we would be letting the operating system wrest control from our carefully optimized program! So, for the few cycles needed to access localQueues_ we use a spin-lock. The boost spin-lock is sufficient, but we would love to remove the boost dependency someday. Implement a modern spin-lock class and place it somewhere like Soul Engine\Source\Parallelism\Thread\Spinlock.h/.cpp

Some helpful links: https://stackoverflow.com/questions/5869825/when-should-one-use-a-spinlock-instead-of-mutex https://www.boost.org/doc/libs/1_68_0/libs/fiber/doc/html/index.html https://github.com/boostorg/fiber

Behemyth avatar Aug 16 '18 06:08 Behemyth