1#ifndef XRPL_CORE_JOBQUEUE_H_INCLUDED
2#define XRPL_CORE_JOBQUEUE_H_INCLUDED
4#include <xrpld/core/ClosureCounter.h>
5#include <xrpld/core/JobTypeData.h>
6#include <xrpld/core/JobTypes.h>
7#include <xrpld/core/detail/Workers.h>
9#include <xrpl/basics/LocalValue.h>
10#include <xrpl/json/json_value.h>
12#include <boost/coroutine/all.hpp>
53 boost::coroutines::asymmetric_coroutine<void>::pull_type
coro_;
54 boost::coroutines::asymmetric_coroutine<void>::push_type*
yield_;
151 if (
auto optionalCountedJob =
388#include <xrpld/core/Coro.ipp>
406 coro->expectEarlyExit();
A generic endpoint for log messages.
A metric for measuring an integral value.
A reference to a handler for performing polled collection.
std::optional< Substitute< Closure > > wrap(Closure &&closure)
Wrap the passed closure with a reference counter.
Coroutines must run to completion.
void join()
Waits until coroutine returns from the user function.
void resume()
Resume coroutine execution.
std::condition_variable cv_
void expectEarlyExit()
Once called, the Coro allows early exit without an assert.
bool runnable() const
Returns true if the Coro is still runnable (has not returned).
bool post()
Schedule coroutine execution.
Coro & operator=(Coro const &)=delete
Coro(Coro_create_t, JobQueue &, JobType, std::string const &, F &&)
boost::coroutines::asymmetric_coroutine< void >::push_type * yield_
void yield() const
Suspend coroutine execution.
boost::coroutines::asymmetric_coroutine< void >::pull_type coro_
Coro(Coro const &)=delete
A pool of threads to perform work.
JobTypeData m_invalidJobData
int getJobLimit(JobType type)
std::shared_ptr< Coro > postCoro(JobType t, std::string const &name, F &&f)
Creates a coroutine and adds a job to the queue which will run it.
std::atomic_bool stopped_
void rendezvous()
Block until no jobs running.
int getJobCountTotal(JobType t) const
Jobs waiting plus running at this priority.
JobTypeData & getJobTypeData(JobType type)
int getJobCountGE(JobType t) const
All waiting jobs at or greater than this priority.
void addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed)
Add multiple load events.
Json::Value getJson(int c=0)
beast::insight::Collector::ptr m_collector
bool addRefCountedJob(JobType type, std::string const &name, JobFunction const &func)
std::unique_ptr< LoadEvent > makeLoadEvent(JobType t, std::string const &name)
Return a scoped LoadEvent.
int getJobCount(JobType t) const
Jobs waiting at this priority.
beast::insight::Hook hook
beast::insight::Gauge job_count
void processTask(int instance) override
Perform a task.
std::atomic_bool stopping_
void finishJob(JobType type)
void getNextJob(Job &job)
std::condition_variable cv_
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
Manages partitions for logging.
Workers is effectively a thread pool.
Singleton class that maintains performance counters and optionally writes Json-formatted data to a di...
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Called to perform tasks as needed.