Protium
Math and Design Features
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Protium::Threads::ThreadingPrototype< Host > Class Template Reference

Prototype of threading policy. More...

#include <ThreadingPolicy.h>

Inheritance diagram for Protium::Threads::ThreadingPrototype< Host >:

Public Types

typedef Host VolatileType
 Use to access Host class from derived templates. More...
 

Detailed Description

template<class Host>
class Protium::Threads::ThreadingPrototype< Host >

Prototype of threading policy.

Use in order to specify threading policy for a class For instance:

template< template<class,class>class threadPolicy = SomeThreadPolicy<MyClass,Mutex> >
class MyClass {
typedef MyClass<threadPolicy> localClass;
typedef SomeThreadPolicy< localClass, Mutex > ThreadModel;
void SomeFunction(){
typename ThreadModel::Lock lock;
(void)lock; // get rid of warning
//Do Something thread-safe here
}
};

Now, you can specify what kind of threaded object you want to use

typedef MyClass<InSingleThread<MyClass, Mutex> > MyThreadedClass;

Is you specifically want something to be instance locked, then it has to inherit from the threading policy.

Like so:

template< template<class,class>class threadPolicy = InstanceLocked<MyClass,Mutex> >
class MyClass : InstanceLocked<MyClass, Mutex> {
typedef MyClass<threadPolicy> localClass;
typedef SomeThreadPolicy< localClass, Mutex > ThreadModel;
void SomeFunction(){
typename ThreadModel::Lock lock(*this);
(void)lock; // get rid of warning
//Do Something thread-safe here
}
};

Definition at line 56 of file ThreadingPolicy.h.

Member Typedef Documentation

template<class Host >
typedef Host Protium::Threads::ThreadingPrototype< Host >::VolatileType

Use to access Host class from derived templates.

Definition at line 59 of file ThreadingPolicy.h.