18 #ifndef UTHREADS_CACHE_H_ 19 #define UTHREADS_CACHE_H_ 22 #include "../generic/IntrusiveContainers.h" 38 IntrusiveStack<uThread> stack;
43 uThreadCache(
size_t size = defaultuThreadCacheSize) : count(0), size(size){};
57 std::unique_lock<std::mutex> mlock(mtx, std::try_to_lock);
59 if(!mlock.owns_lock() || count == size)
return -1;
70 std::unique_lock<std::mutex> mlock(mtx, std::try_to_lock);
72 if(!mlock.owns_lock() || count == 0)
return nullptr;
Data structure to cache uThreads.
Definition: uThreadCache.h:33
uThread * pop()
pop a uThread from the list in FIFO order and return it
Definition: uThreadCache.h:69
user-level threads (fiber)
Definition: uThread.h:63
ssize_t push(uThread *ut)
adds a uThread to the cache
Definition: uThreadCache.h:56