replace LockPtr/ConstLockPtr implementation with a template policy based one
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@508 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
2ada6bd1d7
commit
5e5965fdc1
3 changed files with 57 additions and 17 deletions
|
@ -206,10 +206,6 @@
|
|||
RelativePath="..\..\include\loki\HierarchyGenerators.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\loki\LockingPtr.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\loki\LokiTypeInfo.h"
|
||||
>
|
||||
|
@ -254,10 +250,6 @@
|
|||
RelativePath="..\..\include\loki\static_check.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\loki\Threads.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\loki\Tuple.h"
|
||||
>
|
||||
|
@ -324,6 +316,10 @@
|
|||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\include\loki\LockingPtr.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
|
@ -332,6 +328,10 @@
|
|||
RelativePath=".\Thread.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\loki\Threads.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
#define LOKI_CLASS_LEVEL_THREADING
|
||||
|
||||
#ifndef LOKI_CLASS_LEVEL_THREADING
|
||||
#define LOKI_OBJECT_LEVEL_THREADING
|
||||
#endif
|
||||
|
||||
#include "Thread.h"
|
||||
|
||||
#include <loki/LockingPtr.h>
|
||||
|
@ -29,6 +33,8 @@ int loop = 5;
|
|||
|
||||
struct A
|
||||
{
|
||||
A(){};
|
||||
|
||||
#define DO for(int i=0; i<10000000; i++) g++;
|
||||
|
||||
void print(void* id) const
|
||||
|
@ -54,8 +60,8 @@ struct A
|
|||
}
|
||||
};
|
||||
|
||||
typedef Loki::LockingPtr<A,Loki::Mutex> LPtr;
|
||||
typedef Loki::ConstLockingPtr<A,Loki::Mutex> CLPtr;
|
||||
typedef Loki::Locking<A>::Ptr LPtr;
|
||||
typedef Loki::Locking<A>::ConstPtr CLPtr;
|
||||
|
||||
void* RunLocked(void *id)
|
||||
{
|
||||
|
@ -96,7 +102,7 @@ int main ()
|
|||
for(int i=0; i<numThreads; i++)
|
||||
{
|
||||
Printf("Creating thread %d\n")(i);
|
||||
threads.push_back(new Thread(RunLocked,(void*)i));
|
||||
threads.push_back(new Thread(RunLocked,reinterpret_cast<void*>(i)));
|
||||
}
|
||||
for(int i=0; i<numThreads; i++)
|
||||
threads.at(i)->start();
|
||||
|
@ -111,7 +117,7 @@ int main ()
|
|||
for(int i=0; i<numThreads; i++)
|
||||
{
|
||||
Printf("Creating thread %d\n")(i);
|
||||
threads.push_back(new Thread(Run,(void*)i));
|
||||
threads.push_back(new Thread(Run,reinterpret_cast<void*>(i)));
|
||||
}
|
||||
for(int i=0; i<numThreads; i++)
|
||||
threads.at(i)->start();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue