From 4c44125d372a8731a57cacbe4e386474cdde76ea Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 6 Oct 2022 22:28:23 +0000 Subject: [PATCH] ircd::gpt::samp: Split dispatch branch into memfun. --- include/ircd/gpt/samp.h | 1 + ircd/gpt.cc | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/ircd/gpt/samp.h b/include/ircd/gpt/samp.h index a0c3a6e68..5a168a10d 100644 --- a/include/ircd/gpt/samp.h +++ b/include/ircd/gpt/samp.h @@ -38,6 +38,7 @@ struct ircd::gpt::samp void profile_accumulate(const pipe::prof &); bool retire(pipe::cycle &, const gpt::ctrl &); bool evaluate(pipe::cycle &); + bool dispatche(); uint tokenize(); public: diff --git a/ircd/gpt.cc b/ircd/gpt.cc index 1123f548b..476c00754 100644 --- a/ircd/gpt.cc +++ b/ircd/gpt.cc @@ -820,19 +820,8 @@ ircd::gpt::samp::operator()() { ctx::interruption_point(); - if(dispatch > 0) - { - if(!cycle) - ctrl.prof.released = prof::cycles(); - - queue.emplace_back(*this); - desc.cached = tokens; - tokens += count >= tokens; - ++cycle; - ++count; - --dispatch; + if(dispatche()) return false; - } while(!queue.empty()) { @@ -944,6 +933,33 @@ ircd::gpt::samp::tokenize() return count; } +bool +ircd::gpt::samp::dispatche() +{ + if(!dispatch) + return false; + + assert(accept < 0); + assert(count > 0); + assert(tokens >= count); + assert(cycle < count); + assert(dispatch > 0); + + if(cycle == 0) + { + ctrl.prof.acquired = 0; + ctrl.prof.released = prof::cycles(); + } + + queue.emplace_back(*this); + desc.cached = tokens; + tokens += count >= tokens; + count += 1; + cycle += 1; + dispatch -= 1; + return true; +} + bool ircd::gpt::samp::evaluate(pipe::cycle &cycle) {