A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PDBWork.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 /*
19  * File: PDBWork.h
20  * Author: Chris
21  *
22  * Created on September 25, 2015, 5:19 PM
23  */
24 
25 #ifndef PDBWORK_H
26 #define PDBWORK_H
27 
28 
29 #include <memory>
30 using namespace std;
31 
32 #include "PDBBuzzer.h"
33 #include "PDBLogger.h"
34 #include "PDBWorker.h"
35 #include "PDBWorkerQueue.h"
36 #include <pthread.h>
37 #include <string>
38 
39 // this class wraps up a bit of work that needs to be accomplished...
40 // the idea is that one first obtains a PDBWorker that has been loaded
41 // with this work; they call PDBWorker.execute () which executes the
42 // work, and then they get the result.
43 
44 namespace pdb {
45 
46 // create a smart pointer for PDBWork objects
47 class PDBWork;
48 typedef shared_ptr<PDBWork> PDBWorkPtr;
49 
50 class PDBWork {
51 public:
52  // actually go off and do the work... the worker can optionally invoke
53  // any of the handlers embedded in callerBuzzer to ask the caller to
54  // deal with errors
55  virtual void execute(PDBBuzzerPtr callerBuzzer) = 0;
56 
57  // gets a buzzer that is "linked" to this object; that is, a PDBBuzzer
58  // object that (optionally) overrides PDBBuzzer.handleBuzz () and performs
59  // a callback to this object, invoking specialized code that handles the
60  // event. For example, we might create a buzzer object with a PDBBuzzer.handleBuzz ()
61  // that catches any PDBAlarm (other than PDBAlarm :: WorkAllDone) and then
62  // calls a method on this object to handle the event
63  virtual PDBBuzzerPtr getLinkedBuzzer();
64 
65  // this is called by the PDBWorker class to initiate the work
66  void execute(PDBWorkerQueue* parent, PDBBuzzerPtr callerBuzzer);
67 
68  // gets another worker from the PDBWorkQueue that was used to
69  // create the PDBWorker who is running this guy...
70  PDBWorkerPtr getWorker();
71 
72  // gets access to the logger
73  PDBLoggerPtr getLogger();
74 
75 private:
76  // this is the work queue that this dude came from... used to supply
77  // additional workers, if they are requested
79 };
80 }
81 
82 #endif /* PDBWORK_H */
shared_ptr< PDBWork > PDBWorkPtr
Definition: PDBWork.h:47
PDBWorkerQueue * parent
Definition: PDBWork.h:78
shared_ptr< PDBBuzzer > PDBBuzzerPtr
Definition: PDBBuzzer.h:32
shared_ptr< PDBWorker > PDBWorkerPtr
Definition: PDBWorker.h:40
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40