uThreads  0.3.0
Public Member Functions | List of all members
uThreadCache Class Reference

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...
 
uThreadpop ()
 pop a uThread from the list in FIFO order and return it More...
 

Detailed Description

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.

Member Function Documentation

uThread* uThreadCache::pop ( )
inline

pop a uThread from the list in FIFO order and return it

Returns
nullptr on failure, or a pointer to a uThread on success
ssize_t uThreadCache::push ( uThread ut)
inline

adds a uThread to the cache

Parameters
utpointer to a uThread
Returns
size of the cache if push was successful or -1 if not

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.


The documentation for this class was generated from the following file: