Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | List of all members
Mezzanine::Scripting::Lua::Lua51WorkUnit Class Reference

This is a simple Container of script that will execute every script it is given in order each frame. More...

#include <lua51workunit.h>

+ Inheritance diagram for Mezzanine::Scripting::Lua::Lua51WorkUnit:
+ Collaboration diagram for Mezzanine::Scripting::Lua::Lua51WorkUnit:

Public Member Functions

 Lua51WorkUnit (Lua51ScriptingEngine *TargetRuntime)
 Create a Lua51WorkUnit. More...
 
virtual ~Lua51WorkUnit ()
 Virtual deconstructor.
 
virtual void AddScript (CountedPtr< iScript > ScriptToAdd)
 Adds a script similar to push_back. More...
 
virtual void AddScript (CountedPtr< Lua51Script > ScriptToAdd)
 Adds a script similar to push_back (Actually calls it). More...
 
virtual void AddScript (String Source)
 Add a script by providing it source code. More...
 
iterator begin ()
 Get an iterator to the first script. More...
 
const_iterator begin () const
 Get a const_iterator to the first script. More...
 
virtual void ClearScripts ()
 Remove all the Scripts from this workunit. More...
 
virtual void DoWork (Threading::DefaultThreadSpecificStorage::Type &CurrentThreadStorage)
 Runs all scripts that have been added to this work unit.
 
iterator end ()
 Get an iterator one past the last script. More...
 
const_iterator end () const
 Get a const_iterator one past the last script. More...
 
void erase (CountedPtr< Lua51Script > Target)
 Erase The first found Script use that pointer. More...
 
void erase (iterator Target)
 Remove the target script from the container. More...
 
iterator find (CountedPtr< Lua51Script > Target)
 Get an Iterator to a script from the counted pointer. More...
 
const_iterator find (CountedPtr< Lua51Script > Target) const
 Get an const_iterator to a script from the counted pointer. More...
 
virtual CountedPtr< Lua51ScriptGetLua51Script (Whole Index) const
 Retrieve a Script previously passed in. More...
 
virtual CountedPtr< iScriptGetScript (Whole Index)
 Retrieve a Script previously passed in. More...
 
virtual Whole GetScriptCount () const
 How many Scripts have been added to this workunit. More...
 
void push_back (CountedPtr< Lua51Script > ScriptToAdd)
 Adds a script to be run once each frame. More...
 
virtual void RemoveScript (CountedPtr< iScript > ScriptToRemove)
 Similar to calling erase. More...
 
virtual void RemoveScript (CountedPtr< Lua51Script > ScriptToRemove)
 The Same as calling erase and passing a CountedPtr to a script. More...
 
virtual void RemoveScript (Whole Index)
 Remove a script by index. More...
 
- Public Member Functions inherited from Mezzanine::Scripting::iScriptWorkUnit
virtual ~iScriptWorkUnit ()
 Virtual deconstructor.
 
- Public Member Functions inherited from Mezzanine::Threading::DefaultWorkUnit
 DefaultWorkUnit ()
 Simple constructor.
 
virtual ~DefaultWorkUnit ()
 Virtual destructor, doesn't actually do much.
 
virtual void AddDependency (iWorkUnit *NewDependency)
 Force this WorkUnit to Start after another has completed. More...
 
virtual void ClearDependencies ()
 Drop any information about what work units this one depends on.
 
virtual iWorkUnitGetDependency (Whole Index) const
 This is used to iterate of all the dependencies. More...
 
virtual Whole GetDependencyCount () const
 How many other WorkUnits does this one depend on? More...
 
virtual Whole GetDependentCount (FrameScheduler &SchedulerToCount)
 This returns the count workunits that depend on this work unit. More...
 
virtual Whole GetImmediateDependencyCount () const
 Get the amount of dependencies that directly count on this for access purposes. More...
 
virtual Whole GetPerformance () const
 Get the internal rolling average for querying. More...
 
virtual RollingAverage< Whole > & GetPerformanceLog ()
 Get the internal rolling average for querying. More...
 
virtual RunningState GetRunningState () const
 Retrieves the current RunningState of the thread. More...
 
virtual WorkUnitKey GetSortingKey (FrameScheduler &SchedulerToCount)
 Get the sorting metadata. More...
 
virtual bool IsEveryDependencyComplete ()
 Check if this WorkUnit could concievably run right now. More...
 
virtual void operator() (DefaultThreadSpecificStorage::Type &CurrentThreadStorage)
 This does everything required to track metadata and log work. More...
 
virtual void PrepareForNextFrame ()
 This resets the running state and takes any further action required to use the WorkUnit again.
 
virtual void RemoveDependency (iWorkUnit *RemoveDependency)
 Remove a dependency. More...
 
virtual RunningState TakeOwnerShip ()
 Attempts to atomically start the work unit in the current thread. More...
 
- Public Member Functions inherited from Mezzanine::Threading::iWorkUnit
virtual ~iWorkUnit ()
 Virtual destructor.
 

Additional Inherited Members

- Protected Attributes inherited from Mezzanine::Threading::DefaultWorkUnit
Int32 CurrentRunningState
 This controls do work with this after it has.
 
std::vector< iWorkUnit * > Dependencies
 A collection of of workunits that must be complete before this one can start.
 
DefaultRollingAverage< Whole >::Type PerformanceLog
 A rolling average of execution times.
 

Detailed Description

This is a simple Container of script that will execute every script it is given in order each frame.

This WorkUnit starts with no dependencies, the developer using this must set those, (see Threading::DefaultWorkUnit::AddDependency for details). This is not automatically added to the WorkScheduler on the Entresol, and must be added manually.

Internally this uses an std::vector to store scripts and each frame it will iterate over them and execute them one at a time. This exposes iterators and a few convience function to make the script manageable.

All scripts are stored in CountedPtr to allow for shared ownership.

Definition at line 79 of file lua51workunit.h.

Constructor & Destructor Documentation

Mezzanine::Scripting::Lua::Lua51WorkUnit::Lua51WorkUnit ( Lua51ScriptingEngine TargetRuntime)

Create a Lua51WorkUnit.

Parameters
TargetRuntimeThe Lua runtime to execute Scripts against.

Definition at line 59 of file lua51workunit.cpp.

Member Function Documentation

void Mezzanine::Scripting::Lua::Lua51WorkUnit::AddScript ( CountedPtr< iScript ScriptToAdd)
virtual

Adds a script similar to push_back.

Parameters
ScriptToAddA iScript to add.

Implements Mezzanine::Scripting::iScriptWorkUnit.

Definition at line 69 of file lua51workunit.cpp.

void Mezzanine::Scripting::Lua::Lua51WorkUnit::AddScript ( CountedPtr< Lua51Script ScriptToAdd)
virtual

Adds a script similar to push_back (Actually calls it).

Parameters
ScriptToAddA Lua51Script to add.

Definition at line 80 of file lua51workunit.cpp.

void Mezzanine::Scripting::Lua::Lua51WorkUnit::AddScript ( String  Source)
virtual

Add a script by providing it source code.

Parameters
SourceThe Lua source code to add.

Definition at line 84 of file lua51workunit.cpp.

Lua51WorkUnit::iterator Mezzanine::Scripting::Lua::Lua51WorkUnit::begin ( )

Get an iterator to the first script.

Returns
An iterator.

Definition at line 134 of file lua51workunit.cpp.

Lua51WorkUnit::const_iterator Mezzanine::Scripting::Lua::Lua51WorkUnit::begin ( ) const

Get a const_iterator to the first script.

Returns
A const_iterator.

Definition at line 136 of file lua51workunit.cpp.

void Mezzanine::Scripting::Lua::Lua51WorkUnit::ClearScripts ( )
virtual

Remove all the Scripts from this workunit.

This should run in constant time. It still might be slower than removing and reading just one a few Scripts.

Implements Mezzanine::Scripting::iScriptWorkUnit.

Definition at line 147 of file lua51workunit.cpp.

Lua51WorkUnit::iterator Mezzanine::Scripting::Lua::Lua51WorkUnit::end ( )

Get an iterator one past the last script.

Returns
An iterator

Definition at line 139 of file lua51workunit.cpp.

Lua51WorkUnit::const_iterator Mezzanine::Scripting::Lua::Lua51WorkUnit::end ( ) const

Get a const_iterator one past the last script.

Returns
A const_iterator

Definition at line 141 of file lua51workunit.cpp.

void Mezzanine::Scripting::Lua::Lua51WorkUnit::erase ( CountedPtr< Lua51Script Target)

Erase The first found Script use that pointer.

Parameters
TargetA CountedPtr to a script that has already been added. If the script has not been added this fails silently.
Note
Consider this as Invalidating all iterators to this container. This takes linear time to find the Pointer in the Container, then linear time to erase the entry for each Script after the target script.

Definition at line 107 of file lua51workunit.cpp.

void Mezzanine::Scripting::Lua::Lua51WorkUnit::erase ( Lua51WorkUnit::iterator  Target)

Remove the target script from the container.

Parameters
TargetThe script to remvoe.
Note
This takes linear time to erase the entry for each Script after the target script or constant time if it is the last Script

Definition at line 114 of file lua51workunit.cpp.

Lua51WorkUnit::iterator Mezzanine::Scripting::Lua::Lua51WorkUnit::find ( CountedPtr< Lua51Script Target)

Get an Iterator to a script from the counted pointer.

Parameters
Targeta CountedPtr to convert into an iterator
Returns
If the Script has been added this returns its iterator, otherwise it returns and end() iterator.
Note
Searches in Linear time, likely useless for external use, it is used internally.

Definition at line 87 of file lua51workunit.cpp.

Lua51WorkUnit::const_iterator Mezzanine::Scripting::Lua::Lua51WorkUnit::find ( CountedPtr< Lua51Script Target) const

Get an const_iterator to a script from the counted pointer.

Parameters
Targeta CountedPtr to convert into an const_iterator
Returns
If the Script has been added this returns its const_iterator, otherwise it returns and end() const_iterator.
Note
Searches in Linear time, likely useless for external use, it is used internally.

Definition at line 97 of file lua51workunit.cpp.

CountedPtr< Lua51Script > Mezzanine::Scripting::Lua::Lua51WorkUnit::GetLua51Script ( Whole  Index) const
virtual

Retrieve a Script previously passed in.

Parameters
IndexThe index of the passed parameter to retrun.
Returns
A reference counted pointer to a Lua51Script.

Definition at line 153 of file lua51workunit.cpp.

CountedPtr< iScript > Mezzanine::Scripting::Lua::Lua51WorkUnit::GetScript ( Whole  Index)
virtual

Retrieve a Script previously passed in.

Parameters
IndexThe index of the passed parameter to retrun.
Returns
A reference counted pointer to a iScript.

Implements Mezzanine::Scripting::iScriptWorkUnit.

Definition at line 150 of file lua51workunit.cpp.

Whole Mezzanine::Scripting::Lua::Lua51WorkUnit::GetScriptCount ( ) const
virtual

How many Scripts have been added to this workunit.

Returns
A Whole containing the amount of arguments passed in so far.

Implements Mezzanine::Scripting::iScriptWorkUnit.

Definition at line 144 of file lua51workunit.cpp.

void Mezzanine::Scripting::Lua::Lua51WorkUnit::push_back ( CountedPtr< Lua51Script ScriptToAdd)

Adds a script to be run once each frame.

Parameters
ScriptToAddA CountedPtr to a script that should be run each Frame.
Note
Consider this as Invalidating all iterators to this container.

Definition at line 66 of file lua51workunit.cpp.

void Mezzanine::Scripting::Lua::Lua51WorkUnit::RemoveScript ( CountedPtr< iScript ScriptToRemove)
virtual

Similar to calling erase.

Parameters
ScriptToRemoveA CountedPtr to the script to remove

Implements Mezzanine::Scripting::iScriptWorkUnit.

Definition at line 117 of file lua51workunit.cpp.

void Mezzanine::Scripting::Lua::Lua51WorkUnit::RemoveScript ( CountedPtr< Lua51Script ScriptToRemove)
virtual

The Same as calling erase and passing a CountedPtr to a script.

Parameters
ScriptToRemoveA CountedPtr to the script to remove

Definition at line 128 of file lua51workunit.cpp.

void Mezzanine::Scripting::Lua::Lua51WorkUnit::RemoveScript ( Whole  Index)
virtual

Remove a script by index.

Parameters
IndexThe index of the Script to Remove.

Implements Mezzanine::Scripting::iScriptWorkUnit.

Definition at line 131 of file lua51workunit.cpp.


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