small changes for Threads; add compile test for Threads.h
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@321 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
da979a7e0e
commit
23ade9b6f0
3 changed files with 128 additions and 19 deletions
|
@ -20,7 +20,7 @@
|
|||
#endif
|
||||
|
||||
//#define LOKI_CLASS_LEVEL_THREADING
|
||||
//#define LOKI_OBJECT_LEVEL_THREADING
|
||||
#define LOKI_OBJECT_LEVEL_THREADING
|
||||
|
||||
// Some platforms might have difficulty with this
|
||||
// Need to ifdef around those cases.
|
||||
|
@ -41,6 +41,7 @@ Test::tests_type Test::tests;
|
|||
// is the header inclusion to execute the correspond
|
||||
// unit test.
|
||||
|
||||
#include "ThreadsTest.h"
|
||||
#include "TypelistTest.h"
|
||||
#include "SequenceTest.h"
|
||||
#include "TypeManipTest.h"
|
||||
|
@ -112,6 +113,9 @@ return result;
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.9 2005/10/24 20:35:12 syntheticpp
|
||||
// small changes for Threads; add compile test for Threads.h
|
||||
//
|
||||
// Revision 1.8 2005/10/06 17:50:14 syntheticpp
|
||||
// adding template based list/sequence implementation, should replace LOKI_TYPELIST_, update some files
|
||||
//
|
||||
|
|
79
test/RegressionTest/ThreadsTest.h
Executable file
79
test/RegressionTest/ThreadsTest.h
Executable file
|
@ -0,0 +1,79 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Unit Test for Loki
|
||||
//
|
||||
// Copyright Peter Kümmel 2005
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for any
|
||||
// purpose is hereby granted without fee, provided that this copyright and
|
||||
// permissions notice appear in all copies and derivatives.
|
||||
//
|
||||
// This software is provided "as is" without express or implied warranty.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef THREADSTEST_H
|
||||
#define THREADSTEST_H
|
||||
|
||||
#include <loki/Threads.h>
|
||||
#include "UnitTest.h"
|
||||
|
||||
namespace ThreadsTestPrivate
|
||||
{
|
||||
class SingleLevel : public Loki::SingleThreaded<SingleLevel>
|
||||
{
|
||||
int i;
|
||||
public:
|
||||
void test()
|
||||
{
|
||||
Lock lock0;
|
||||
Lock lock(*this);
|
||||
Lock lockThis(this);
|
||||
i++;
|
||||
}
|
||||
};
|
||||
|
||||
class ClassLevel : public Loki::ClassLevelLockable<ClassLevel>
|
||||
{
|
||||
int i;
|
||||
public:
|
||||
void test()
|
||||
{
|
||||
Lock lock0;
|
||||
Lock lock(*this);
|
||||
Lock lockThis(this);
|
||||
i++;
|
||||
}
|
||||
};
|
||||
|
||||
class ObjectLevel : public Loki::ObjectLevelLockable<ObjectLevel>
|
||||
{
|
||||
int i;
|
||||
public:
|
||||
void test()
|
||||
{
|
||||
//Lock lock0_must_not_compile;
|
||||
Lock lock(*this);
|
||||
Lock lockThis(this);
|
||||
i++;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class ThreadsTest : public Test
|
||||
{
|
||||
public:
|
||||
ThreadsTest() : Test("Threads.h") {}
|
||||
|
||||
virtual void execute(TestResult &result)
|
||||
{
|
||||
printName(result);
|
||||
|
||||
bool r = true; // TODO some tests
|
||||
|
||||
testAssert("Threads",r,result);
|
||||
|
||||
std::cout << '\n';
|
||||
}
|
||||
} threadsTest;
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue