VR-Forces 4.1 Class Documentation
asyncJob.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright 2010 VT MAK
3 *******************************************************************************/
4 
7 
8 #pragma once
9 
10 #include <vlutil/vlPrint.h>
11 #include <vlutil/vlExceptions.h>
12 
13 #include "asyncJobMapEntry.h"
14 #include "asyncJobServer.h"
15 
16 #include "tbb/task.h"
17 
18 #include "boost/function.hpp"
19 
24 
25 #include <vrfutil/vrfutilDefines.h>
26 
27 struct job_canceled{}; //exception for termination of a task during execution.
28 struct outside_search_radius{}; //exception for graph search has gone too far out of the way.
29 
31 {
32  DtJobCancelStruct(size_t id, DtAsyncJobServer* jobServer)
33  : myId(id)
34  , myJobServer(jobServer)
35  {
36 
37  }
38 
39  bool operator()() const
40  {
41  return myJobServer->jobStatus(myId) == canceled;
42  }
43 
44  size_t myId;
46 };
47 
48 //An asynchronous job that can be added to and executed by a job server.
49 class DT_DLL_vrfutil DtAsyncJob : public tbb::task
50 {
51 public:
52  DtAsyncJob();
53 
54  virtual ~DtAsyncJob();
55 
56  //Do not override. Calls onExecute, then onException if there is an exception thrown.
57  virtual task* execute();
58 
60  virtual task* onExecute() = 0;
62  virtual task* onException() = 0;
63 
64 protected:
67  friend class DtAsyncJobServer;
69  size_t myId;
70 };
71 

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)