Classes | Public Types | Public Member Functions | Public Attributes

Wizt::AsynchronCreator Class Reference

A Creator object that generates its content on demand, deferred, in a subthread, via the VISH Thread Interface VTask. More...

#include <AsynchronCreator.hpp>

List of all members.

Classes

Public Types

Public Member Functions

Public Attributes


Detailed Description

A Creator object that generates its content on demand, deferred, in a subthread, via the VISH Thread Interface VTask.

class   MyObject : public VObject
{
        Slot            ThreadManagerSlot;

public:
        MyObject(...)
        {
                ThreadManagerSlot = addParameter( "computationThread", 2, new VValueParameter<VThreadManager>() );
        }

        override bool update(VRequest&Req, double precision)
        {
                ...
                // First, get a field object from somewhere
        RefPtr<Field>&myField = ...;
                // We seek to work on the field's global Creator
        RefPtr<AnalyticCreator> AC = myField->getCreator();
                if (!AC)
                {
                        // If there is no creator yet, define one.
                        // No action will be performed here, and some action
                        // will only be triggered if the data of this Creator
                        // will actually be requested elsewhere.
                        myField->setCreator( new AnalyticCreator( ThreadManagerSlot->param ) );
                        touch();
                }

                //
                // If running, terminate the execution of the data graph.
                // This is one of the rare cases where the update() function 
                // may return false. What this means is that the data graph will
                // no longer be traversed this time, and the global request for
                // creation of data will be denied. Then, this request may be
                // restarted, but the application can do something else in the
                // meanwhile. Alternatively, could also wait here, until the
                // thread has finished. Though, this were a waste of computational
                // resources to just spend time here with doing nothing.
                //
                if (AC && AC->isRunning() )
                        return false;

                // analytic creator exists and can be used to do something with it
                // but most likely we just want to return now, since all activity
                // will be done by the AnalyticCreator object.
                ...
                return true;
        }
};

Member Data Documentation

Flag to determine whether the deferred operation shall be executed asynchroneously, i.e.

within another thread.