2023-06-24 03:14:17 +02:00
/*
ACTIVITY . hpp - elementary operation to be handled by the scheduler
Copyright ( C ) Lumiera . org
2023 , Hermann Vosseler < Ichthyostega @ web . de >
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation ; either version 2 of
the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
/** @file activity.hpp
* * Descriptor for a piece of operational logic performed by the scheduler .
* * The Scheduler in Lumiera ' s Vault coordinates the rendering activities ,
* * by passing and responding to _Activity messages , _ thereby observing
* * temporal limits ( deadlines ) and dependency constraints . A predefined
* * and fixed set of _Activity verbs_ defines atomic operations the engine
* * is able to perform , directed by the scheduler . Complex calculation
* * tasks are constructed from interconnected activities , passing through
* * the messaging and priority queue of the scheduler . While an Activity
* * is in processing , the corresponding descriptor data record is maintained
* * by the BlockStream custom memory manager .
* *
* * @ note right now this is a pipe dream
* * @ see ////TODO_test usage example
* * @ see scheduler . cpp implementation
* *
* * @ todo WIP - WIP - WIP 6 / 2023 » Playback Vertical Slice «
* *
*/
# ifndef SRC_VAULT_GEAR_ACTIVITY_H_
# define SRC_VAULT_GEAR_ACTIVITY_H_
# include "vault/common.hpp"
2023-07-06 16:35:42 +02:00
# include "vault/gear/job.h"
# include "lib/time/timevalue.hpp"
2023-06-24 03:14:17 +02:00
//#include "lib/symbol.hpp"
//#include "lib/util.hpp"
//#include <string>
namespace vault {
namespace gear {
2023-07-06 16:35:42 +02:00
using lib : : time : : TimeValue ;
using lib : : time : : TimeVar ;
2023-06-24 03:14:17 +02:00
// using util::isnil;
// using std::string;
2023-07-06 16:35:42 +02:00
/**
* Wrapper to hold Time values in trivially constructible union .
* By an unfortunate design decision , lib : : time : : Time values are
* non - copyable , which prevents placing them into POD data
*
* @ todo 7 / 2023 this decision should be reverted //////////////////////////////////////////////////////////TICKET #1261 : reconsider (im)mutability of time entities
*/
class Instant
{
int64_t microTick_ ;
public :
Instant ( ) = default ; // @suppress("Class members should be properly initialized")
Instant ( TimeValue time )
: microTick_ { _raw ( time ) }
{ }
operator TimeVar ( ) const
{
return TimeValue { microTick_ } ;
}
// default copy acceptable
} ;
2023-06-24 03:14:17 +02:00
/**
2023-06-26 02:16:50 +02:00
* Term to describe an Activity ,
* to happen within the Scheduler ' s control flow .
2023-07-06 16:35:42 +02:00
* @ note Activity is a » POD with constructor «
* - trivially * destructible *
* - trivially * copyable *
* - standard layout
2023-06-24 03:14:17 +02:00
*/
class Activity
{
public :
2023-07-06 16:35:42 +02:00
/** All possible kinds of activities */
enum Verb { INVOKE ///< dispatch a JobFunctor into a worker thread
2023-06-26 02:16:50 +02:00
, TIMESTART ///< signal start of some processing (for timing measurement)
, TIMESTOP ///< correspondingly signal end of some processing
, NOTIFY ///< push a message to another Activity
2023-07-05 15:10:34 +02:00
, GATE ///< probe window + count-down; activate next Activity, else re-schedule
2023-07-06 16:35:42 +02:00
, FEED ///< supply additional payload data for a preceding Activity
, POST ///< post a message providing a chain of further time-bound Activities
2023-06-26 02:16:50 +02:00
, TICK ///< internal engine »heart beat« for internal maintenance hook(s)
} ;
const Verb verb_ ;
2023-07-06 16:35:42 +02:00
/**
* Activities are organised into _chains_
* to represent _relations_ based on verbs .
*/
Activity * next ;
/* === Activity Data Arguments === */
/** Payload data to provide */
struct Feed
{
size_t one ;
size_t two ;
} ;
/** Timing observation to propagate */
struct Timing
{
Instant instant ;
size_t quality ;
} ;
/** Access gate condition to evaluate */
struct Condition
{
int rest ; ///< alive while rest > 0
Instant dead ; ///< alive while time < dead
} ;
/** Time window to define for activation */
struct TimeWindow
{
Instant life ;
Instant dead ;
} ;
/** External work functor to activate */
struct Invocation
{
JobFunctor * task ;
Instant time ;
} ;
/** Notification towards another Activity */
struct Notification
{
Activity * target ;
size_t report ;
} ;
/** Storage of Argument data dependent on Activity::verb_ */
union ArgumentData
{
Feed feed ;
Timing timing ;
Condition condition ;
TimeWindow timeWindow ;
Invocation invocation ;
Notification notification ;
} ;
ArgumentData data_ ;
2023-06-26 02:16:50 +02:00
explicit
Activity ( Verb verb )
: verb_ { verb }
2023-07-06 16:35:42 +02:00
, next { nullptr }
2023-06-24 03:14:17 +02:00
{ }
// using default copy/assignment
} ;
} } // namespace vault::gear
# endif /*SRC_VAULT_GEAR_ACTIVITY_H_*/