CernVM-FS
2.12.0
|
#include <concurrency.h>
Public Member Functions | |
virtual | ~ConcurrentWorker () |
virtual bool | Initialize () |
virtual void | TearDown () |
Protected Member Functions | |
ConcurrentWorker () | |
ConcurrentWorkers < DerivedWorkerT > * | master () const |
Private Member Functions | |
void | RegisterMaster (ConcurrentWorkers< DerivedWorkerT > *master) |
Private Member Functions inherited from SingleCopy | |
SingleCopy () | |
Private Attributes | |
ConcurrentWorkers < DerivedWorkerT > * | master_ |
Friends | |
class | ConcurrentWorkers< DerivedWorkerT > |
Base class for worker classes that should be used in a ConcurrentWorkers swarm. These classes need to fulfill a number of requirements in order to satisfy the needs of the ConcurrentWorkers template.
Requirements: -> needs to define the following types:
-> implement a constructor that takes a pointer to its worker_context as its only parameter: AwesomeWorker(const AwesomeWorker::worker_context*) Note: do not rely on the context object to be available after the constructor has returned!
-> needs to define the calling-operator expecting one parameter of type: const expected_data& and returning void This will be invoked for every new job the worker should process
-> inside the implementation of the described calling-operator it needs to invoke either: master()->JobSuccessful(const returned_data&) or: master()->JobFailed(const returned_data&) as its LAST operation before returning. This will keep track of finished jobs and inform the user of Concurrent- Workers about finished jobs.
-> [optional] overwrite Initialize() and/or TearDown() to do environmental setup work, before or respectively after jobs will be processed
General Reminder: You will be running in a multi-threaded environment here! Buckle up and make suitable preparations to shield yourself from serious head-ache.
Note: This implements a Curiously Recurring Template Pattern (http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern)
DerivedWorkerT | the class name of the inheriting class (f.e. class AwesomeWorker : public ConcurrentWorker<AwesomeWorker>) |
Definition at line 669 of file concurrency.h.
|
inlinevirtual |
Definition at line 671 of file concurrency.h.
|
inlineprotected |
The actual job-processing entry point. See the description of the inheriting class requirements to learn about the semantics of this methods. DO NOT FORGET TO CALL master()->JobSuccessful() OR master()->JobFinished() at the end of thismethod!!
Note: There is no way to generally define this operator, it is therefore commented out and placed here just as a reminder.
data | the data to be processed. |
Definition at line 702 of file concurrency.h.
|
inlinevirtual |
Does general initialization before any jobs will get scheduled. You do not need to up-call this initialize method, since it is seen as a dummy here.
Definition at line 679 of file concurrency.h.
|
inlineprotected |
Gets a pointer to the ConcurrentWorkers object that this worker resides in
Definition at line 709 of file concurrency.h.
Referenced by swissknife::CommandMigrate::AbstractMigrationWorker< DerivedT >::operator()().
|
inlineprivate |
Definition at line 713 of file concurrency.h.
|
inlinevirtual |
Does general clean-up after the last job was processed in the worker object and it is about to vanish. You do not need to up-call this method.
Definition at line 685 of file concurrency.h.
|
friend |
Definition at line 712 of file concurrency.h.
|
private |
Definition at line 718 of file concurrency.h.