This is a simple Container of script that will execute every script it is given in order each frame. More...
#include <lua51workunit.h>
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< Lua51Script > | GetLua51Script (Whole Index) const |
Retrieve a Script previously passed in. More... | |
virtual CountedPtr< iScript > | GetScript (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 iWorkUnit * | GetDependency (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. | |
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.
Mezzanine::Scripting::Lua::Lua51WorkUnit::Lua51WorkUnit | ( | Lua51ScriptingEngine * | TargetRuntime | ) |
Create a Lua51WorkUnit.
TargetRuntime | The Lua runtime to execute Scripts against. |
Definition at line 59 of file lua51workunit.cpp.
|
virtual |
Adds a script similar to push_back.
ScriptToAdd | A iScript to add. |
Implements Mezzanine::Scripting::iScriptWorkUnit.
Definition at line 69 of file lua51workunit.cpp.
|
virtual |
Adds a script similar to push_back (Actually calls it).
ScriptToAdd | A Lua51Script to add. |
Definition at line 80 of file lua51workunit.cpp.
|
virtual |
Add a script by providing it source code.
Source | The 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.
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.
Definition at line 136 of file lua51workunit.cpp.
|
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.
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.
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.
Target | A CountedPtr to a script that has already been added. If the script has not been added this fails silently. |
Definition at line 107 of file lua51workunit.cpp.
void Mezzanine::Scripting::Lua::Lua51WorkUnit::erase | ( | Lua51WorkUnit::iterator | Target | ) |
Remove the target script from the container.
Target | The script to remvoe. |
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.
Target | a CountedPtr to convert into an iterator |
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.
Target | a CountedPtr to convert into an const_iterator |
Definition at line 97 of file lua51workunit.cpp.
|
virtual |
Retrieve a Script previously passed in.
Index | The index of the passed parameter to retrun. |
Definition at line 153 of file lua51workunit.cpp.
|
virtual |
Retrieve a Script previously passed in.
Index | The index of the passed parameter to retrun. |
Implements Mezzanine::Scripting::iScriptWorkUnit.
Definition at line 150 of file lua51workunit.cpp.
|
virtual |
How many Scripts have been added to this workunit.
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.
ScriptToAdd | A CountedPtr to a script that should be run each Frame. |
Definition at line 66 of file lua51workunit.cpp.
|
virtual |
Similar to calling erase.
ScriptToRemove | A CountedPtr to the script to remove |
Implements Mezzanine::Scripting::iScriptWorkUnit.
Definition at line 117 of file lua51workunit.cpp.
|
virtual |
The Same as calling erase and passing a CountedPtr to a script.
ScriptToRemove | A CountedPtr to the script to remove |
Definition at line 128 of file lua51workunit.cpp.
|
virtual |
Remove a script by index.
Index | The index of the Script to Remove. |
Implements Mezzanine::Scripting::iScriptWorkUnit.
Definition at line 131 of file lua51workunit.cpp.