~marcustomlinson/dspatchables/trunk

« back to all changes in this revision

Viewing changes to include/dspatch/DspThreadNull.h

  • Committer: Marcus Tomlinson
  • Date: 2015-04-05 22:25:24 UTC
  • mfrom: (1.1.10 trunk)
  • Revision ID: marcus.tomlinson@canonical.com-20150405222524-urntp725s5hbk2im
Merged add_basic_components

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/************************************************************************
 
2
DSPatch - Cross-Platform, Object-Oriented, Flow-Based Programming Library
 
3
Copyright (c) 2012-2015 Marcus Tomlinson
 
4
 
 
5
This file is part of DSPatch.
 
6
 
 
7
GNU Lesser General Public License Usage
 
8
This file may be used under the terms of the GNU Lesser General Public
 
9
License version 3.0 as published by the Free Software Foundation and
 
10
appearing in the file LGPLv3.txt included in the packaging of this
 
11
file. Please review the following information to ensure the GNU Lesser
 
12
General Public License version 3.0 requirements will be met:
 
13
http://www.gnu.org/copyleft/lgpl.html.
 
14
 
 
15
Other Usage
 
16
Alternatively, this file may be used in accordance with the terms and
 
17
conditions contained in a signed written agreement between you and
 
18
Marcus Tomlinson.
 
19
 
 
20
DSPatch is distributed in the hope that it will be useful,
 
21
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
23
************************************************************************/
 
24
 
 
25
#ifndef DSPTHREADNULL_H
 
26
#define DSPTHREADNULL_H
 
27
 
 
28
//=================================================================================================
 
29
/// Cross-platform, object-oriented thread
 
30
 
 
31
/**
 
32
An class that is required to run actions in a parallel thread can be derived from DspThread in
 
33
order to inherit multi-threading abilities. The Start() method initiates a parallel thread and
 
34
executes the private virtual _Run() method in that thread. The derived class must override this
 
35
_Run() method with one that executes the required parallel actions. Other threads may use the
 
36
static MsSleep() and SetPriority() methods without having to derive from, or create an instance of
 
37
DspThread. Priority for the created thread, or calling threads (via SetPriority()), may be selected
 
38
from the public enumeration: Priority.
 
39
*/
 
40
 
 
41
class DspThread
 
42
{
 
43
public:
 
44
    DspThread()
 
45
    {
 
46
    }
 
47
 
 
48
    virtual ~DspThread()
 
49
    {
 
50
    }
 
51
 
 
52
    enum Priority
 
53
    {
 
54
        IdlePriority,
 
55
 
 
56
        LowestPriority,
 
57
        LowPriority,
 
58
        NormalPriority,
 
59
        HighPriority,
 
60
        HighestPriority,
 
61
 
 
62
        TimeCriticalPriority
 
63
    };
 
64
 
 
65
    virtual void Start(Priority priority)
 
66
    {
 
67
    }
 
68
    virtual void Stop();
 
69
    static void SetPriority(Priority priority)
 
70
    {
 
71
    }
 
72
    static void MsSleep(int milliseconds)
 
73
    {
 
74
    }
 
75
};
 
76
 
 
77
//=================================================================================================
 
78
/// Cross-platform, object-oriented mutex
 
79
 
 
80
/**
 
81
DspMutex is a simple mutex that can lock a critical section of code for exclusive access by
 
82
the calling thread. Other threads attempting to acquire a lock while another has acquired it
 
83
will wait at the Lock() method call until the thread that owns the mutex calls Unlock().
 
84
*/
 
85
 
 
86
class DspMutex
 
87
{
 
88
public:
 
89
    DspMutex()
 
90
    {
 
91
    }
 
92
 
 
93
    virtual ~DspMutex()
 
94
    {
 
95
    }
 
96
 
 
97
    static void Lock()
 
98
    {
 
99
    }
 
100
    static void Unlock()
 
101
    {
 
102
    }
 
103
};
 
104
 
 
105
//=================================================================================================
 
106
/// Cross-platform, object-oriented conditional wait
 
107
 
 
108
/**
 
109
A wait condition works like an indefinite sleep. When a thread calls the Wait() function it
 
110
is put to sleep until it is woken by the WakeAll() function of the same DspWaitCondition object.
 
111
This is used to synchronize actions between threads.
 
112
*/
 
113
 
 
114
class DspWaitCondition
 
115
{
 
116
public:
 
117
    DspWaitCondition()
 
118
    {
 
119
    }
 
120
 
 
121
    virtual ~DspWaitCondition()
 
122
    {
 
123
    }
 
124
 
 
125
    static void Wait(DspMutex& mutex)
 
126
    {
 
127
    }
 
128
    static void WakeAll()
 
129
    {
 
130
    }
 
131
};
 
132
 
 
133
//=================================================================================================
 
134
 
 
135
#endif  // DSPTHREADNULL_H