From 3539db640767e6dafa652864fc5a5445db4ee697 Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Tue, 30 May 2017 14:21:12 -0400 Subject: Add deferrable callbacks Deferrable callbacks delay callback invocation until a pre configured length of time has elapsed. One example scenario where deferrable callbacks help is to avoid oscillation when testing a condition and making callbacks frequently. Signed-off-by: Brad Bishop Change-Id: I180c99b57ec1c9bde4da76d947a026f809341c8a --- src/templates/conditional.mako.cpp | 7 +++++++ src/templates/generated.mako.hpp | 2 ++ 2 files changed, 9 insertions(+) (limited to 'src/templates') diff --git a/src/templates/conditional.mako.cpp b/src/templates/conditional.mako.cpp index 3cc9564..229b3d6 100644 --- a/src/templates/conditional.mako.cpp +++ b/src/templates/conditional.mako.cpp @@ -1,3 +1,10 @@ +% if c.defer: +std::make_unique>( +${indent(1)}ConfigPropertyCallbackGroups::get()[${c.graph}], +${indent(1)}*ConfigConditions::get()[${c.condition}], +${indent(1)}${c.defer})\ +% else: std::make_unique>( ${indent(1)}ConfigPropertyCallbackGroups::get()[${c.graph}], ${indent(1)}*ConfigConditions::get()[${c.condition}])\ +% endif\ diff --git a/src/templates/generated.mako.hpp b/src/templates/generated.mako.hpp index 914b065..51462b1 100644 --- a/src/templates/generated.mako.hpp +++ b/src/templates/generated.mako.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include #include #include "count.hpp" #include "data_types.hpp" @@ -13,6 +14,7 @@ #include "sdevent.hpp" using namespace std::string_literals; +using namespace std::chrono_literals; namespace phosphor { -- cgit v1.2.1