Added ConstLockingPtr class.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@498 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
963c55994f
commit
7acf9ff6be
2 changed files with 77 additions and 2 deletions
|
@ -31,7 +31,7 @@ struct A
|
|||
{
|
||||
#define DO for(int i=0; i<10000000; i++) g++;
|
||||
|
||||
void print(void* id)
|
||||
void print(void* id) const
|
||||
{
|
||||
DO;Printf("%p: ----------------\n")(id);
|
||||
DO;Printf("%p: ---------------\n")(id);
|
||||
|
@ -55,10 +55,11 @@ struct A
|
|||
};
|
||||
|
||||
typedef Loki::LockingPtr<A,Loki::Mutex> LPtr;
|
||||
typedef Loki::ConstLockingPtr<A,Loki::Mutex> CLPtr;
|
||||
|
||||
void* RunLocked(void *id)
|
||||
{
|
||||
A a;
|
||||
volatile A a;
|
||||
static Loki::Mutex m;
|
||||
for(int i=0; i<loop; i++)
|
||||
{
|
||||
|
@ -68,6 +69,18 @@ void* RunLocked(void *id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void* RunConstLocked(void *id)
|
||||
{
|
||||
const volatile A a;
|
||||
static Loki::Mutex m;
|
||||
for(int i=0; i<loop; i++)
|
||||
{
|
||||
CLPtr l(a,m);
|
||||
l->print(id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* Run(void *id)
|
||||
{
|
||||
A a;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue