Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::WorkProcessor Class Referenceabstract

Abstract work processor – takes work units and turns them into WorkResult instances. More...

#include <mitsuba/core/sched.h>

+ Inheritance diagram for mitsuba::WorkProcessor:

Public Member Functions

virtual ref< WorkUnitcreateWorkUnit () const =0
 Create a work unit of the proper type and size. More...
 
virtual ref< WorkResultcreateWorkResult () const =0
 Create a work result of the proper type and size. More...
 
virtual ref< WorkProcessorclone () const =0
 Create a copy of this work processor instance. More...
 
virtual void prepare ()=0
 Called once before processing starts. More...
 
virtual void process (const WorkUnit *workUnit, WorkResult *workResult, const bool &stop)=0
 Process a work unit and store the computed results. More...
 
virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
- Public Member Functions inherited from mitsuba::SerializableObject
 SerializableObject (Stream *stream, InstanceManager *manager)
 Unserialize a serializable object. More...
 
virtual void serialize (Stream *stream, InstanceManager *manager) const =0
 Serialize this object to a stream. More...
 
- Public Member Functions inherited from Object
 Object ()
 Construct a new object. More...
 
int getRefCount () const
 Return the current reference count. More...
 
void incRef () const
 Increase the reference count of the object by one. More...
 
void decRef (bool autoDeallocate=true) const
 Decrease the reference count of the object and possibly deallocate it. More...
 
virtual std::string toString () const
 Return a human-readable string representation of the object's contents. More...
 

Static Public Attributes

static Classm_theClass
 
- Static Public Attributes inherited from mitsuba::SerializableObject
static Classm_theClass
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

virtual ~WorkProcessor ()
 Virtual destructor. More...
 
 WorkProcessor ()
 Protected constructors. More...
 
 WorkProcessor (Stream *stream, InstanceManager *manager)
 
SerializableObjectgetResource (const std::string &name)
 Look up a named resource, which has been bound to the associated parallel process. More...
 
- Protected Member Functions inherited from mitsuba::SerializableObject
 SerializableObject ()
 Construct a serializable object. More...
 
virtual ~SerializableObject ()
 Virtual deconstructor. More...
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Protected Attributes

std::map< std::string,
SerializableObject * > 
m_resources
 

Friends

class Scheduler
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static void staticInitialization ()
 Initializes the built-in reference count debugger (if enabled) More...
 
static void staticShutdown ()
 Free the memory taken by staticInitialization() More...
 

Detailed Description

Abstract work processor – takes work units and turns them into WorkResult instances.

When executing a parallel task using Mitsuba's scheduling system, the actual work is done in an implementation of this interface.

The class is serializable so that it can be sent over the network if required. It is possible to keep local state in WorkProcessor instances (e.g. scratch space for computations), though anything not returned in the form of a WorkResult will eventually be lost. Each Worker (both locally and remotely) has its own WorkProcessor, and therefore no form of locking is required within instances of this class.

See Also
WorkUnit
WorkResult
ParallelProcess
Scheduler

Constructor & Destructor Documentation

virtual mitsuba::WorkProcessor::~WorkProcessor ( )
inlineprotectedvirtual

Virtual destructor.

mitsuba::WorkProcessor::WorkProcessor ( )
inlineprotected

Protected constructors.

mitsuba::WorkProcessor::WorkProcessor ( Stream stream,
InstanceManager manager 
)
inlineprotected

Member Function Documentation

virtual ref<WorkProcessor> mitsuba::WorkProcessor::clone ( ) const
pure virtual

Create a copy of this work processor instance.

Remarks
In practice, before the cloned work processor is actually used, its prepare() method will be called. Therefore, any state that is initialized in prepeare() does not have to be copied.
virtual ref<WorkResult> mitsuba::WorkProcessor::createWorkResult ( ) const
pure virtual

Create a work result of the proper type and size.

virtual ref<WorkUnit> mitsuba::WorkProcessor::createWorkUnit ( ) const
pure virtual

Create a work unit of the proper type and size.

Implemented in mitsuba::ParticleTracer.

virtual const Class* mitsuba::WorkProcessor::getClass ( ) const
virtual

Retrieve this object's class.

Reimplemented from mitsuba::SerializableObject.

Reimplemented in mitsuba::ParticleTracer.

SerializableObject* mitsuba::WorkProcessor::getResource ( const std::string &  name)
protected

Look up a named resource, which has been bound to the associated parallel process.

Throws an exception if the resource is not known / bound.

virtual void mitsuba::WorkProcessor::prepare ( )
pure virtual

Called once before processing starts.

This is useful for allocating scratch space or resolving references to resource objects. Lengthy computations should be performed in process() instead of here, since this this method will be called while the central scheduler lock is held. A thrown exception will lead to the termination of the parallel process.

Implemented in mitsuba::ParticleTracer.

virtual void mitsuba::WorkProcessor::process ( const WorkUnit workUnit,
WorkResult workResult,
const bool stop 
)
pure virtual

Process a work unit and store the computed results.

The active parameter can be used to signal a premature stop of the execution flow. In this case, the work result is allowed to be undefined (it will simply be ignored). A thrown exception will lead to the termination of the parallel process.

Implemented in mitsuba::ParticleTracer.

Friends And Related Function Documentation

friend class Scheduler
friend

Member Data Documentation

std::map<std::string, SerializableObject *> mitsuba::WorkProcessor::m_resources
protected
Class* mitsuba::WorkProcessor::m_theClass
static

The documentation for this class was generated from the following file: