File: ThreadsTest.h

package info (click to toggle)
libloki 0.1.7-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,608 kB
  • sloc: cpp: 30,475; ansic: 1,974; makefile: 365; php: 316; perl: 108
file content (87 lines) | stat: -rw-r--r-- 1,863 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
///////////////////////////////////////////////////////////////////////////////
// Unit Test for Loki
//
// Copyright Peter Kmmel 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

// $Id: ThreadsTest.h 760 2006-10-17 20:36:13Z syntheticpp $


#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++;
        }
    };

#if defined(LOKI_CLASS_LEVEL_THREADING) || defined(LOKI_OBJECT_LEVEL_THREADING)

    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++;
        }
    };

#endif

}//namespace Loki


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