20 class ScheduleableHandle;
58 bool is_unique_event =
false);
116 continuing_ = continuing;
193 continuing_, is_unique_event_);
238 return label_.c_str();
268 void precedes(Vertex & consumer,
const std::string & reason =
"")
const;
290 void precedes(Vertex * consumer,
const std::string & reason =
"")
const{
379#ifndef DO_NOT_DOCUMENT
381 virtual void onSchedulerAssignment_() {
382 setupDummyPrecedence_ThisMethodToGoAwayOnceDaveAddsPhaseSupportToDAG();
384 void setupDummyPrecedence_ThisMethodToGoAwayOnceDaveAddsPhaseSupportToDAG();
398 return scheduleable_handle_count_;
430 scheduleable_(scheduleable)
451 operator bool()
const {
452 return scheduler_ !=
nullptr;
456 return scheduler_ == other.scheduler_;
477 Vertex * vertex_ =
nullptr;
487 bool is_gop_ =
false;
490 mutable uint32_t scheduleable_handle_count_ = 0;
495 virtual void reclaim_() {}
508 bool continuing_ =
true;
512 const bool is_unique_event_ =
false;
534 if(scheduleable_ && --scheduleable_->scheduleable_handle_count_ == 0) {
535 scheduleable_->reclaim_();
542 ++scheduleable_->scheduleable_handle_count_;
557 scheduleable_ = orig.scheduleable_;
568 scheduleable_(scheduleable)
580 scheduleable_(&scheduleable)
596 return scheduleable_;
602 return (scheduleable_ == rhs.scheduleable_);
608 return !(scheduleable_ == rhs.scheduleable_);
614 scheduleable_ = rhs.scheduleable_;
625 inline Scheduleable &
operator>>(Scheduleable & producer, Scheduleable & consumer)
627 sparta_assert(producer.getSchedulingPhase() == consumer.getSchedulingPhase(),
628 "The Producer: " << producer.getLabel() <<
" scheduling phase is not equal to"
629 " the consumer: " << consumer.getLabel());
630 producer.precedes(consumer);
File that defines the Clock class.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
File that contains the macro used to generate the class callbacks.
A representation of simulated time.
Scheduler * getScheduler() const
Scheduler::Tick getTick(const Cycle &cycle) const
Return the tick corresponding to the given cycle.
A light-weight reference counting handle for Scheduleables – DOES NOT delete.
bool operator==(const ScheduleableHandle &rhs) const
ScheduleableHandle & operator=(const ScheduleableHandle &rhs)
Assignment.
ScheduleableHandle(Scheduleable *scheduleable)
Create a ScheduleableHandle with a given Scheduleable pointer. NO reference counting is performed wit...
ScheduleableHandle(const ScheduleableHandle &orig)
Copy a Handle, increment the count.
ScheduleableHandle()=default
Create an empty Handle.
bool operator!=(const ScheduleableHandle &rhs) const
ScheduleableHandle(Scheduleable &scheduleable)
Create a ScheduleableHandle with a given Scheduleable reference. NO reference counting is performed w...
Scheduleable * operator->() const
Get at the underlying Scheduleable.
An internal class used in Scheduleble to cache a pointer to the scheduler.
A class that defines the basic scheduling interface to the Scheduler. Not intended to be used by mode...
void setContinuing(bool continuing)
This event, if continuing == true, will keep the simulation running.
SpartaHandler & getHandler()
Get the consumer handler/callback associated with this event.
void setScheduler(Scheduler *sched)
Set the Scheduler of this Scheduleable, and set the local vertex_ to a new vertex from the Vertex Fac...
virtual void eventCancelled_()
void schedule(Clock::Cycle delay)
Schedule an event in the future using the pre-set Clock.
void precedes(Vertex *consumer, const std::string &reason="") const
Have this Scheduleable precede a Vertex.
virtual void scheduleRelativeTick(const Scheduler::Tick rel_tick, Scheduler *const scheduler)
Schedule this event on a relative scheduler tick.
PrecedenceGroup getGroupID() const
Get the group ID.
uint32_t PrecedenceGroup
Typedef defining the precedence group ID.
void addDelay(Clock::Cycle delay)
Add to the delay for this event.
void cancel(Clock::Cycle rel_cycle)
Cancel this Scheduleable at the given time, if placed on the Scheduler.
void schedule()
Schedule this event with its pre-set delay using the pre-set Clock.
const char * getLabel() const
Get the internal label.
void cancel()
Cancel all the times that this Scheduleable was placed on the Scheduler.
bool isScheduled(Clock::Cycle rel_cycle) const
Return true if this Scheduleable was scheduled on the given relative cycle.
Scheduler * getScheduler(const bool must_exist=true)
Get the scheduler this Scheduleable is assigned to.
void precedes(Scheduleable &consumer, const std::string &reason="")
Have this Scheduleable precede another.
bool isOrphan() const
Return true if this scheduleable is not associated with a vertex.
const SpartaHandler & getHandler() const
Get the consumer handler/callback associated with this event.
Scheduleable(const Scheduleable &)=default
Allow copies.
void setHandler(const SpartaHandler &handler)
Set the consumer handler/callback associated with this event.
bool unlink(Scheduleable *w)
Unlink this scheduleables vertex from another scheduleables vertex.
Vertex * getVertex()
get the internal Vertex of this scheduleable
void precedes(Vertex &consumer, const std::string &reason="") const
Have this Scheduleable precede a Vertex.
void setGroupID(const PrecedenceGroup gid)
bool isScheduled() const
Return true if this scheduleable was scheduled at all.
void schedule(const Clock *clk)
Schedule this event with its pre-set delay using the given clock.
const Scheduler * getScheduler(const bool must_exist=true) const
Get the scheduler this Scheduleable is assigned to.
Clock::Cycle getDelay() const
Get the delay associated with this event.
Scheduleable(Scheduleable &&) noexcept=default
Allow moves. Marked as noexcept to force containers to use it.
void setVertex()
Set the local vertex_ to a new vertex from the Vertex Factory. This needs to happen before the Schedu...
void setDelay(Clock::Cycle delay)
Set a fixed delay for this event.
void setLabel(const char *label)
Set a new label for this Scheduleable – used in debugging.
void setScheduleableClock(const Clock *clk)
Set the clock and scheduler of this Scheduleable.
bool isContinuing() const
Is this Event continuing?
virtual void setGroupID_(const PrecedenceGroup gid)
Set the group ID of this Scheduleable's derivatives.
void schedule(Clock::Cycle delay, const Clock *clk)
Schedule an event in the future using the given Clock.
SchedulingPhase getSchedulingPhase() const
Get the internal phase number.
virtual ~Scheduleable()=default
Destructor.
PrecedenceSetup scheduler_
Cache a pointer to the scheduler used.
uint32_t getScheduleableHandleCount_() const
const Clock * local_clk_
A local clock for speed.
void precedes(Scheduleable *consumer, const std::string &reason="")
Have this Scheduleablee precede another.
SpartaHandler consumer_event_handler_
The Consumer callback registered with the Event.
Scheduleable(const SpartaHandler &consumer_event_handler, Clock::Cycle delay, SchedulingPhase sched_phase, bool is_unique_event=false)
Construct a Scheduleable object.
A class that lets you schedule events now and in the future.
bool isScheduled(const Scheduleable *scheduleable) const
Is the given Scheduleable item anywhere (in time now -> future) on the Scheduler?
void cancelEvent(const Scheduleable *scheduleable)
Cancel the given Scheduleable if on the Scheduler.
void scheduleEvent(Scheduleable *scheduleable, Tick rel_time, uint32_t dag_group=0, bool continuing=true, bool add_if_not_scheduled=false)
Schedule a single event. This method should also be thread safe.
uint64_t Tick
Typedef for our unit of time.
The is the base class for user defined blocks in simulation.
Macros for handling exponential backoff.
std::enable_if< std::is_base_of< EventNode, ScheduleableTypeA >::value, constGlobalOrderingPoint >::type & operator>>(ScheduleableTypeA &producer, const GlobalOrderingPoint &consumer)
Place a precedence between a Scheduleable object and a GlobalOrderingPoint.
SchedulingPhase
The SchedulingPhases used for events (Tick, Update, PortUpdate, etc)