diff --git a/src/ripple/core/JobCoro.h b/src/ripple/core/JobCoro.h index fa6f02682..8bc21698f 100644 --- a/src/ripple/core/JobCoro.h +++ b/src/ripple/core/JobCoro.h @@ -39,6 +39,7 @@ struct JobCoro_create_t { }; } // detail +/** Coroutines must run to completion. */ class JobCoro : public std::enable_shared_from_this { private: @@ -52,6 +53,9 @@ private: std::condition_variable cv_; boost::coroutines::asymmetric_coroutine::pull_type coro_; boost::coroutines::asymmetric_coroutine::push_type* yield_; +#ifndef NDEBUG + bool finished_ = false; +#endif public: // Private: Used in the implementation @@ -59,6 +63,12 @@ public: JobCoro(detail::JobCoro_create_t, JobQueue&, JobType, std::string const&, F&&); + // Not copy-constructible or assignable + JobCoro(JobCoro const&) = delete; + JobCoro& operator= (JobCoro const&) = delete; + + ~JobCoro(); + /** Suspend coroutine execution. Effects: The coroutine's stack is saved. diff --git a/src/ripple/core/JobCoro.ipp b/src/ripple/core/JobCoro.ipp index 3083c3a01..da9f0413f 100644 --- a/src/ripple/core/JobCoro.ipp +++ b/src/ripple/core/JobCoro.ipp @@ -36,10 +36,19 @@ JobCoro::JobCoro(detail::JobCoro_create_t, JobQueue& jq, JobType type, yield_ = &do_yield; yield(); fn(shared_from_this()); +#ifndef NDEBUG + finished_ = true; +#endif }, boost::coroutines::attributes (1024 * 1024)) { } +inline +JobCoro::~JobCoro() +{ + assert(finished_); +} + inline void JobCoro::yield() const