Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cJobThread.h
Go to the documentation of this file.
1 //
5 //
6 
7 #ifndef _INC_cJobThread_H
8 #define _INC_cJobThread_H
9 #ifndef NO_PRAGMA_ONCE
10 #pragma once
11 #endif
12 
13 #include "cJobThreadSet.h"
14 
15 namespace GrayLib
16 {
19 
21  : public cThreadNamed<cJobThread>
22  {
26 
27  // TODO
28 
30 
31  private:
32  cJobPtr m_pJob;
33  cJobThreadMgr* m_pParentSet;
34 
35  protected:
36  virtual bool ThreadTick() override;
37 
38  public:
39  cJobThread();
40  virtual ~cJobThread();
41 
42  STDMETHOD_(cString, get_Name)() const
43  {
44  if (m_pJob != nullptr)
45  {
46  return m_pJob->get_Name();
47  }
48  return "JobThreadIdle"; // no current job running. idle.
49  }
50  cJobPtr get_Job() const
51  {
53  return m_pJob;
54  }
55 
56  void AssignJob(cJobBase* pJob, cJobThreadMgr* pParentSet)
57  {
59  ASSERT(pJob != nullptr);
60  ASSERT(pParentSet != nullptr);
61  ASSERT(m_pJob == nullptr); // was idle.
62  m_pJob = pJob; // nullptr = not in use.
63  m_pParentSet = pParentSet;
64  }
65 
67  };
69 
70  class GRAYLIB_LINK cJobThreadMgr : public cJobThreadSet<cJobThread>
71  {
76 
77  // TODO
78 
79  friend class cJobThread;
80  public:
81  cJobThreadMgr(int iMaxThreads = 32);
82  ~cJobThreadMgr();
83 
84  HRESULT ScheduleJob(cJobBase* pJob, TIMESYSD_t mSecDelay);
85  void OnTickJobs();
86  };
87 };
88 #endif // _INC_cJobThread_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: cJobBase.h:23
Definition: cJobThread.h:71
Definition: cJobThreadSet.h:76
Definition: cJobThread.h:22
STDMETHOD_(cString, get_Name)() const
Definition: cJobThread.h:42
UNITTEST2_PREDEF(cJobThread)
cJobPtr get_Job() const
Definition: cJobThread.h:50
void AssignJob(cJobBase *pJob, cJobThreadMgr *pParentSet)
Definition: cJobThread.h:56
Definition: cThread.h:256
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
class __DECL_IMPORT cJobThreadMgr
Definition: cJobThread.h:18
cRefPtr< cJobThread > cJobThreadPtr
Definition: cJobThread.h:68
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28