1
/************************************************************************
2
DSPatch - Cross-Platform, Object-Oriented, Flow-Based Programming Library
3
Copyright (c) 2012-2015 Marcus Tomlinson
5
This file is part of DSPatch.
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.
16
Alternatively, this file may be used in accordance with the terms and
17
conditions contained in a signed written agreement between you and
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
************************************************************************/
25
#ifndef DSPTHREADNULL_H
26
#define DSPTHREADNULL_H
28
//=================================================================================================
29
/// Cross-platform, object-oriented thread
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.
65
virtual void Start(Priority priority)
69
static void SetPriority(Priority priority)
72
static void MsSleep(int milliseconds)
77
//=================================================================================================
78
/// Cross-platform, object-oriented mutex
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().
105
//=================================================================================================
106
/// Cross-platform, object-oriented conditional wait
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.
114
class DspWaitCondition
121
virtual ~DspWaitCondition()
125
static void Wait(DspMutex& mutex)
128
static void WakeAll()
133
//=================================================================================================
135
#endif // DSPTHREADNULL_H