mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
@@ -57,12 +57,7 @@ struct Coro_create_t
|
||||
class JobQueue : private Workers::Callback
|
||||
{
|
||||
public:
|
||||
enum class QueueState
|
||||
{
|
||||
Accepting,
|
||||
Stopping,
|
||||
Stopped
|
||||
};
|
||||
enum class QueueState { Accepting, Stopping, Stopped };
|
||||
|
||||
/** Coroutines must run to completion. */
|
||||
class Coro : public std::enable_shared_from_this<Coro>
|
||||
@@ -178,13 +173,14 @@ public:
|
||||
template <typename JobHandler>
|
||||
bool
|
||||
addJob(JobType type, std::string const& name, JobHandler&& jobHandler)
|
||||
requires std::is_void_v<std::invoke_result_t<JobHandler>>
|
||||
requires std::is_void_v<std::invoke_result_t<JobHandler>>
|
||||
{
|
||||
if (queueState_ != QueueState::Accepting)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return addJobNoStatusCheck(type, name, std::forward<JobHandler>(jobHandler));
|
||||
return addJobNoStatusCheck(
|
||||
type, name, std::forward<JobHandler>(jobHandler));
|
||||
}
|
||||
|
||||
/** Creates a coroutine and adds a job to the queue which will run it.
|
||||
@@ -293,8 +289,11 @@ private:
|
||||
|
||||
template <typename JobHandler>
|
||||
bool
|
||||
addJobNoStatusCheck(JobType type, std::string const& name, JobHandler&& jobHandler)
|
||||
requires std::is_void_v<std::invoke_result_t<JobHandler>>
|
||||
addJobNoStatusCheck(
|
||||
JobType type,
|
||||
std::string const& name,
|
||||
JobHandler&& jobHandler)
|
||||
requires std::is_void_v<std::invoke_result_t<JobHandler>>
|
||||
{
|
||||
if (auto optionalCountedJob =
|
||||
jobCounter_.wrap(std::forward<JobHandler>(jobHandler)))
|
||||
|
||||
@@ -310,7 +310,8 @@ JobQueue::stop()
|
||||
|
||||
if (!queueState_.compare_exchange_strong(accepting, QueueState::Stopping))
|
||||
{
|
||||
XRPL_ASSERT(false, "Incorrect queueState, should be accepting but not!");
|
||||
XRPL_ASSERT(
|
||||
false, "Incorrect queueState, should be accepting but not!");
|
||||
}
|
||||
std::map<void*, std::weak_ptr<Coro>> suspendedCoros;
|
||||
{
|
||||
@@ -327,7 +328,10 @@ JobQueue::stop()
|
||||
{
|
||||
// We don't allow any new jobs from outside when we are
|
||||
// stopping, but we should allow new jobs from inside the class.
|
||||
addJobNoStatusCheck(coroPtr->type_, coroPtr->name_, [coroPtr]() { coroPtr->resume(); });
|
||||
addJobNoStatusCheck(
|
||||
coroPtr->type_, coroPtr->name_, [coroPtr]() {
|
||||
coroPtr->resume();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user