resonance 1.0.1
Loading...
Searching...
No Matches
ticktask.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4
5#include "app/attachment.h"
6#include "mid/tick.h"
7#include "sch/cmdid.h"
8#include "sch/tickclock.h"
9
29class TickTask : public Attachment {
30public:
39 TickTask(Sch::TickClock *pClock, int nPeriod, int bAligned);
40
47 virtual ~TickTask();
48
59 virtual void Print(std::ostream &stream);
60
70 virtual int Tick(int nElapsedTicks) = 0;
71
84 void Start(int nEpochOffset);
85
94 void Run();
95
105 void Stop();
106
107private:
108 Sch::TickClock *mClock; // +0x08 the clock the task is posted against
109 Sch::CmdID mCommand; // +0x0c the handle of the queued command, -2 while none is queued
110 int mPeriod; // +0x10 ticks between one run and the next
111 // Tick the next run is due at, both read and advanced by Run(). Defaults to Sch::Tick's
112 // positive infinity sentinel.
113 int mNextTick; // +0x14
114 // Tick the elapsed count is measured from. Defaults to the same sentinel.
115 int mEpoch; // +0x18
116 // Non-zero when the first run waits for the next multiple of mPeriod.
117 int mAligned; // +0x1c
118};
Attachment()
Definition attachment.h:26
Handle that identifies one batch of commands the scheduler has queued.
Definition cmdid.h:35
Pausable view of scheduler time, together with the tempo that maps it to a song position.
Definition tickclock.h:40
void Run()
Run Tick() for the run now due and post the next one.
TickTask(Sch::TickClock *pClock, int nPeriod, int bAligned)
virtual ~TickTask()
Withdraw the queued command.
virtual int Tick(int nElapsedTicks)=0
Run the task.
void Stop()
Withdraw the queued command and forget its handle.
virtual void Print(std::ostream &stream)
Write the task to a diagnostic stream.
void Start(int nEpochOffset)
Post the task on its clock.