mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Annotates JustInTimeActor as force inline.
This commit is contained in:
parent
731dc350b4
commit
5309ac7c30
@ -10,6 +10,7 @@
|
|||||||
#define JustInTime_h
|
#define JustInTime_h
|
||||||
|
|
||||||
#include "../Concurrency/AsyncTaskQueue.hpp"
|
#include "../Concurrency/AsyncTaskQueue.hpp"
|
||||||
|
#include "ForceInline.hpp"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
A JustInTimeActor holds (i) an embedded object with a run_for method; and (ii) an amount
|
A JustInTimeActor holds (i) an embedded object with a run_for method; and (ii) an amount
|
||||||
@ -27,7 +28,7 @@ template <class T, int multiplier = 1, int divider = 1, class LocalTimeScale = H
|
|||||||
template<typename... Args> JustInTimeActor(Args&&... args) : object_(std::forward<Args>(args)...) {}
|
template<typename... Args> JustInTimeActor(Args&&... args) : object_(std::forward<Args>(args)...) {}
|
||||||
|
|
||||||
/// Adds time to the actor.
|
/// Adds time to the actor.
|
||||||
inline void operator += (const LocalTimeScale &rhs) {
|
forceinline void operator += (const LocalTimeScale &rhs) {
|
||||||
if(multiplier != 1) {
|
if(multiplier != 1) {
|
||||||
time_since_update_ += rhs * multiplier;
|
time_since_update_ += rhs * multiplier;
|
||||||
} else {
|
} else {
|
||||||
@ -37,24 +38,26 @@ template <class T, int multiplier = 1, int divider = 1, class LocalTimeScale = H
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Flushes all accumulated time and returns a pointer to the included object.
|
/// Flushes all accumulated time and returns a pointer to the included object.
|
||||||
inline T *operator->() {
|
forceinline T *operator->() {
|
||||||
flush();
|
flush();
|
||||||
return &object_;
|
return &object_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a pointer to the included object without flushing time.
|
/// Returns a pointer to the included object without flushing time.
|
||||||
inline T *last_valid() {
|
forceinline T *last_valid() {
|
||||||
return &object_;
|
return &object_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flushes all accumulated time.
|
/// Flushes all accumulated time.
|
||||||
void flush() {
|
forceinline void flush() {
|
||||||
if(!is_flushed_) {
|
if(!is_flushed_) {
|
||||||
is_flushed_ = true;
|
is_flushed_ = true;
|
||||||
if(divider == 1) {
|
if(divider == 1) {
|
||||||
object_.run_for(time_since_update_.template flush<TargetTimeScale>());
|
object_.run_for(time_since_update_.template flush<TargetTimeScale>());
|
||||||
} else {
|
} else {
|
||||||
object_.run_for(time_since_update_.template divide<TargetTimeScale>(LocalTimeScale(divider)));
|
const auto duration = time_since_update_.template divide<TargetTimeScale>(LocalTimeScale(divider));
|
||||||
|
if(duration > TargetTimeScale(0))
|
||||||
|
object_.run_for(duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user