uThreads
0.3.0
|
Data structure to cache uThreads. More...
#include <uThreadCache.h>
Public Member Functions | |
uThreadCache (size_t size=defaultuThreadCacheSize) | |
ssize_t | push (uThread *ut) |
adds a uThread to the cache More... | |
uThread * | pop () |
pop a uThread from the list in FIFO order and return it More... | |
Data structure to cache uThreads.
uThreadCache is a linked list of uThreads using and intrusive container to cache all terminated uThreads. Instead of destroying the memory allocated for the stack, simply reset the stack pointer and push it to the cache.
|
inline |
|
inline |
adds a uThread to the cache
ut | pointer to a uThread |
This function tries to push a uThread into the cache structure. If the cache is full or the mutex cannot be acquired immediately the operation has failed and the function returns -1. Otherwise, it adds the uThread to the list and return the size of the cache.