OpenZWave Library  1.6.0
Thread.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Thread.h
4 //
5 // Cross-platform threads
6 //
7 // Copyright (c) 2010 Mal Lansell <mal@lansell.org>
8 // All rights reserved.
9 //
10 // SOFTWARE NOTICE AND LICENSE
11 //
12 // This file is part of OpenZWave.
13 //
14 // OpenZWave is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU Lesser General Public License as published
16 // by the Free Software Foundation, either version 3 of the License,
17 // or (at your option) any later version.
18 //
19 // OpenZWave is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU Lesser General Public License for more details.
23 //
24 // You should have received a copy of the GNU Lesser General Public License
25 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
26 //
27 //-----------------------------------------------------------------------------
28 #ifndef _Thread_H
29 #define _Thread_H
30 
31 #include <string>
32 #include "Defs.h"
33 #include "platform/Wait.h"
34 
35 namespace OpenZWave
36 {
37  class ThreadImpl;
38  class Event;
39 
43  class Thread: public Wait
44  {
45  public:
46  typedef void (*pfnThreadProc_t)( Event* _exitEvent, void* _context );
47 
52  Thread( string const& _name );
53 
65  bool Start( pfnThreadProc_t _pfnThreadProc, void* _context );
66 
74  bool Stop();
75 
80  void Sleep( uint32 _millisecs );
81 
82  protected:
86  virtual bool IsSignalled();
87 
92  virtual ~Thread();
93 
94  private:
95  ThreadImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of a thread.
96  Event* m_exitEvent;
97  };
98 
99 } // namespace OpenZWave
100 
101 #endif //_Thread_H
102 
bool Start(pfnThreadProc_t _pfnThreadProc, void *_context)
Definition: Thread.cpp:73
friend class ThreadImpl
Definition: Wait.h:45
Definition: Bitfield.h:34
Platform-independent definition of event objects.
Definition: Event.h:40
Implements a platform-independent thread management class.
Definition: Thread.h:43
bool Stop()
Definition: Thread.cpp:86
void(* pfnThreadProc_t)(Event *_exitEvent, void *_context)
Definition: Thread.h:46
unsigned int uint32
Definition: Defs.h:95
Platform-independent definition of Wait objects.
Definition: Wait.h:42
Thread(string const &_name)
Definition: Thread.cpp:48
void Sleep(uint32 _millisecs)
Definition: Thread.cpp:107
virtual bool IsSignalled()
Definition: Thread.cpp:119
virtual ~Thread()
Definition: Thread.cpp:61