C++ TargetRTS
Loading...
Searching...
No Matches
RTJob.h
1/*
2 * Licensed Materials - Property of HCL and/or IBM
3 * Copyright HCL Technologies Ltd. 2016, 2021. All Rights Reserved.
4 * Copyright IBM Corporation 1999, 2016. All Rights Reserved.
5 *
6 * U.S. Government Users Restricted Rights - Use, duplication or
7 * disclosure restricted by GSA ADP Schedule.
8 */
9
10#ifndef __RTJob_h__
11#define __RTJob_h__ included
12
13#ifdef PRAGMA
14#pragma interface
15#endif
16
17#ifndef __RTConfig_h__
18#include <RTConfig.h>
19#endif
20
21class RTMutex;
22
42class RTJob
43{
44public:
45 enum Phase
46 {
47 created, // initialization
48 running, // most of the time will be spent in this state
49 finished // job finished and thread gone
50 };
51
52 // these are intended for use from "outside" the job
53 RTJob( void );
54 virtual ~RTJob( void );
55
56 // these can be used by anyone
57 virtual const char * name( void ) const = 0;
58 RTS_INLINE Phase phase( void ) const;
59
60 // the thread responsible for the job will invoke this function
61 virtual void mainLoop( void ) = 0;
62
63 // the thread destructor uses this function
64 virtual void kill( void ) = 0;
65
66private:
67 Phase _phase;
68
69protected:
70#if USE_THREADS
71 RTMutex * _mutex;
72#endif
73
74 RTS_INLINE void enter( Phase );
75
76private:
77 // unavailable methods
78 RTJob( const RTJob & );
79 RTJob & operator=( const RTJob & );
80};
81
82#if RTS_INLINES
83#include <RTJob.inl>
84#endif
85
86#endif // __RTJob_h__
An object associated with a thread which captures its current state and implements its behavior.
Definition: RTJob.h:43