MPMA Framework 0.4
|
The Base MPMA Framework. More...
Classes | |
class | RouterOutput |
Implementations of this are output targets which can accept debug data from a RouterInput and output it to anything it likes. More... | |
class | RouterInput |
The program will send it's debug data to instances of this. This will take data and marshell it to all attached outputs. More... | |
class | RouterOutputFile |
A simple RouterInputOutput implementation that writes output to a file (overridding the file). More... | |
class | RouterOutputStdout |
A simple RouterInputOutput implementation that writes output to a stdout. More... | |
class | Filename |
Represents a file name or directory name, which can navigated or created. This can be constructed using a either windows or a linux style path. Names that begin with ~ are relative to the users home directory. A filename may be in relative form or as an absolute path. More... | |
class | FileUtils |
File system utilities. More... | |
struct | SystemInfo |
Information about the system. These are readable anytime after init. Values which are not possible to obtain will be populated with sane defaults. More... | |
class | MutexLock |
A (re-entrant safe) lock based on the operating system's mutexes. More... | |
class | TakeMutexLock |
Used to lock/unlock a MutexLock automatically using scope. The lock is released on dustruction. More... | |
class | SpinLock |
A light-weight spin-lock (NOT re-entrant safe from the same thread) that reverts to a sleeplock on single cpu systems. This is a reference counted object, so all copies of the object still refer to the same lock. More... | |
class | TakeSpinLock |
Used to lock/unlock a spinlock automatically using scope. The lock is released on destruction. More... | |
class | RWSleepLock |
ReaderWriter sleep-lock (re-entrant safe). Read locks don't block each other, but Write locks are exclusive to all other locks. This is a reference counted object, so all copies of the object still refer to the same lock. More... | |
class | TakeRWSleepLock |
Used to lock/unlock a RWSleepLock automatically using scope. The lock is released on dustruction. More... | |
class | BlockingObject |
An object that can be used to block a thread until another thread signals it to resume. This is a reference counted object, so all copies of the object still refer to the same lock. More... | |
class | AutoDelete |
Automatically free a single object when this loses scope. More... | |
class | AutoDeleteArray |
Automatically free an array of objects when this loses scope. More... | |
class | ReferenceCountedData |
Deriving from this allows multiple instances of a class to share data, which will be automatically freed when the last instance is freed. More... | |
class | InitAndShutdown |
You MUST declare this (and only 1 of it) at the start of the scope in which you want the framework to be used. It will handle all setup and cleanup required. Most likely you want to do this at the start of main(). More... | |
union | ThreadParam |
A user-defined parameter passed to the thread procedure. More... | |
class | Thread |
Represents a thread. More... | |
class | ThreadPool |
A pool of pre-created threads. More... | |
class | Timer |
A timer. More... | |
class | Vary |
A variable that can have eithar an integral, real, or string type. It can convert itself between the different types. More... | |
class | VaryString |
This is the same as Vary, except it is always has the type of "string". More... | |
Typedefs | |
typedef void(* | ThreadFunc )(class Thread &, ThreadParam) |
A callback function for the thread's procedure. This function should monitor the IsEnding() method of the provided Thread class, and terminate if it ever returns true. | |
Enumerations | |
enum | ThreadPriority { THREAD_LOW, THREAD_NORMAL, THREAD_HIGH } |
Thread priorities. More... | |
Functions | |
std::string | GetCallStack () |
Returns a string representing the call stack for the current thread. Note that there is a decent amount of overhead involved in this. | |
RouterInput & | ErrorReport () |
Attach outputs to this to recieve error messages from the framework. | |
void | AtomicIntInc (volatile nuint *pint) |
Atomically increments an integer. | |
void | AtomicIntDec (volatile nuint *pint) |
Atomically decrements an integer. | |
nsint | AtomicIntAdd (volatile nsint *pint, nsint addValue) |
Atomically adds one integer to another and returns the value of the original. | |
bool | AtomicCompareExchange (volatile nuint *pInt, nuint expectedValue, nuint newValue, volatile nuint &outResultValue) |
Compares expectedValue with the value at pInt, and if they are the same, sets pInt to newValue and returns true with outResultValue set to newValue. If they are different then pInt is unaffected, and returns false with outResultValue set to the value that was found at pInt. | |
void | Sleep (nuint time) |
Causes the current thread to block for at least time (in milliseconds). 0 just forces a yield. | |
template<typename T > | |
bool | AtomicCompareExchange (T **ptrToReplace, T *ptrExpected, T *ptrToSet, T *&outResultValue) |
Compares ptrExpected with the value at ptrToReplace, and if they are the same, sets ptrToReplace to ptrToSet and returns true with outResultValue set to ptrToSet. If they are different then ptrToReplace is unaffected, and returns false with outResultValue set to the value that was found at ptrToReplace. | |
nuint | GetThreadUniqueIdentifier () |
Gets a value that is unique to the calling thread. Any given thread will always return the same value. | |
template<typename FuncType , FuncType userFunc, typename UserParamType > | |
void | ExecuteThreadedTask (nuint count, UserParamType userParam) |
The Base MPMA Framework.
enum MPMA::ThreadPriority |
Thread priorities.
void MPMA::ExecuteThreadedTask | ( | nuint | count, |
UserParamType | userParam | ||
) |
Executes a function in parallel using multiple threads (1 per cpu core). The function should take 2 parameters: a nuint for the unique 0-based count index passed to it, and the user-supplied parameter. Example:
If you have a function:
inline void Foo(int i, float *param)
{
param[i]+=123.456f;
}
And you wanted to call that function 1000 times total, with i ranging from 0 to 999, you would write:
ExecuteThreadedTask<void(*)(int,float*), Foo)>(1000, myArrayOfFloats);