~ubuntu-branches/debian/experimental/nzbget/experimental

« back to all changes in this revision

Viewing changes to Thread.h

  • Committer: Package Import Robot
  • Author(s): Andreas Moog
  • Date: 2014-12-25 12:58:06 UTC
  • mfrom: (1.2.1) (3.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20141225125806-vnzgajhm7mju9933
Tags: 14.1+dfsg-1
* New Upstream release (Closes: #768863)
* debian/patches:
  - Remove 0010_unnecessary_gcryptdep.patch, included upstream
  - Refresh remaining patches
* debian/control:
  - Remove no longer needed build-depends on libpar2-dev and libsigc++-dev
* debian/nzbget.conf
  - Update sample configuration file to include new options introduced by
    new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  This file is part of nzbget
3
 
 *
4
 
 *  Copyright (C) 2004 Sven Henkel <sidddy@users.sourceforge.net>
5
 
 *  Copyright (C) 2007-2010 Andrey Prygunkov <hugbug@users.sourceforge.net>
6
 
 *
7
 
 *  This program is free software; you can redistribute it and/or modify
8
 
 *  it under the terms of the GNU General Public License as published by
9
 
 *  the Free Software Foundation; either version 2 of the License, or
10
 
 *  (at your option) any later version.
11
 
 *
12
 
 *  This program is distributed in the hope that it will be useful,
13
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 *  GNU General Public License for more details.
16
 
 *
17
 
 *  You should have received a copy of the GNU General Public License
18
 
 *  along with this program; if not, write to the Free Software
19
 
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 
 *
21
 
 * $Revision: 397 $
22
 
 * $Date: 2011-05-24 14:52:41 +0200 (Tue, 24 May 2011) $
23
 
 *
24
 
 */
25
 
 
26
 
 
27
 
#ifndef THREAD_H
28
 
#define THREAD_H
29
 
 
30
 
class Mutex
31
 
{
32
 
private:
33
 
        void*                                   m_pMutexObj;
34
 
        
35
 
public:
36
 
                                                        Mutex();
37
 
                                                        ~Mutex();
38
 
        void                                    Lock();
39
 
        void                                    Unlock();
40
 
};
41
 
 
42
 
#ifdef HAVE_SPINLOCK
43
 
class SpinLock
44
 
{
45
 
private:
46
 
#ifdef WIN32
47
 
        void*                                   m_pSpinLockObj;
48
 
#else
49
 
        volatile void*                  m_pSpinLockObj;
50
 
#endif
51
 
        
52
 
public:
53
 
                                                        SpinLock();
54
 
                                                        ~SpinLock();
55
 
        void                                    Lock();
56
 
        void                                    Unlock();
57
 
};
58
 
#endif
59
 
 
60
 
class Thread
61
 
{
62
 
private:
63
 
        static Mutex*                   m_pMutexThread;
64
 
        static int                              m_iThreadCount;
65
 
        void*                                   m_pThreadObj;
66
 
        bool                                    m_bRunning;
67
 
        bool                                    m_bStopped;
68
 
        bool                                    m_bAutoDestroy;
69
 
 
70
 
#ifdef WIN32
71
 
        static void __cdecl     thread_handler(void* pObject);
72
 
#else
73
 
        static void                             *thread_handler(void* pObject);
74
 
#endif
75
 
 
76
 
public:
77
 
                                                        Thread();
78
 
        virtual                                 ~Thread();
79
 
        static void                             Init();
80
 
        static void                             Final();
81
 
 
82
 
        virtual void                    Start();
83
 
        virtual void                    Stop();
84
 
        bool                                    Kill();
85
 
 
86
 
        bool                                    IsStopped() { return m_bStopped; };
87
 
        bool                                    IsRunning()     const { return m_bRunning; }
88
 
        void                                    SetRunning(bool bOnOff) { m_bRunning = bOnOff; }
89
 
        bool                                    GetAutoDestroy() { return m_bAutoDestroy; }
90
 
        void                                    SetAutoDestroy(bool bAutoDestroy) { m_bAutoDestroy = bAutoDestroy; }
91
 
        static int                              GetThreadCount();
92
 
 
93
 
protected:
94
 
        virtual void                    Run() {}; // Virtual function - override in derivatives
95
 
};
96
 
 
97
 
#endif