VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
asyncJob.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
11 #include <vrfutil/vrfutilDefines.h>
12 
13 #include <vlutil/vlPrint.h>
14 #include <vlutil/vlExceptions.h>
15 
16 #include "asyncJobMapEntry.h"
17 #include "asyncJobServer.h"
18 
20 #include <vrfutil/objectCounter.h>
21 
22 #include <tbb/task.h>
23 
24 #include <boost/function.hpp>
25 
26 class DtAsyncJob;
27 
29 struct job_canceled{};
30 
34 {
35 public:
36  DtJobCancelledFunc(const DtAsyncJob& job);
37  bool operator()() const;
38 
39 protected:
40  const DtAsyncJob& job;
41 };
42 
49  : public tbb::task
50  , public DtAlgorithmManager
51 #ifdef DtObjectDebugger_Enable
52  , public DtObjectDebugger<DtAsyncJob>
53 #endif
54 {
55 public:
57  DtAsyncJob();
58 
60  virtual ~DtAsyncJob();
61 
63  virtual task* execute();
64 
66  virtual task* onExecute() = 0;
67 
69  virtual task* onException() = 0;
70 
72  virtual void tick();
73 
76  virtual boost::shared_ptr<DtAsyncJobMapEntry> getEntry() const = 0;
77 
79  virtual void setEntry(boost::shared_ptr<DtAsyncJobMapEntry>) = 0;
80 
82  bool cancel() const;
83 
84 protected:
86 };
87 
93 {
94 public:
95  boost::shared_ptr<DtAsyncJobMapEntry> getEntry() const;
96  void setEntry(boost::shared_ptr<DtAsyncJobMapEntry>);
97 
98 protected:
99  boost::weak_ptr<DtAsyncJobMapEntry> myEntry;
100 };
101 
107 {
108 public:
109  boost::shared_ptr<DtAsyncJobMapEntry> getEntry() const;
110  void setEntry(boost::shared_ptr<DtAsyncJobMapEntry>);
111 
112  task* execute();
113 
114 protected:
115  boost::shared_ptr<DtAsyncJobMapEntry> myEntry;
116 };
117 
Concrete job class which manages a weak pointer to it&#39;s job map entry. Using this job will require th...
Definition: asyncJob.h:92
virtual void setEntry(boost::shared_ptr< DtAsyncJobMapEntry >)=0
Set the job entry.
virtual boost::shared_ptr< DtAsyncJobMapEntry > getEntry() const =0
Returns the entry associated with this task. If it is null the task is no longer needed.
An asynchronous job that can be added to and executed by a job server. Since this class derives from ...
Definition: asyncJob.h:48
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:31
Default on in debug, off in release.
Definition: objectCounter.h:27
Concrete job class which manages a shared pointer to it&#39;s job map entry. Using this job does not requ...
Definition: asyncJob.h:106
virtual bool cancel() const
Returns true if no longer needed.
DtAsyncJobServer * myServer
Definition: asyncJob.h:85
#define DT_DLL_vrfutil
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfutilDefines.h:34
virtual task * execute()
Do not override. Calls onExecute, then onException if there is an exception thrown.
Manages async job objects.
Definition: asyncJobServer.h:75
Exception for termination of a task during execution.
Definition: asyncJob.h:29
boost::weak_ptr< DtAsyncJobMapEntry > myEntry
Definition: asyncJob.h:99
boost::shared_ptr< DtAsyncJobMapEntry > myEntry
Definition: asyncJob.h:115
General interface which can be passed into an algorithm to control its behavior.
Definition: algorithmManager.h:24
const DtAsyncJob & job
Definition: asyncJob.h:40
For passing to algorithms which may take long enough that they need to check if they can been cancell...
Definition: asyncJob.h:33

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)