X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fdmclock%2Fsupport%2Fsrc%2Frun_every.h;fp=src%2Fceph%2Fsrc%2Fdmclock%2Fsupport%2Fsrc%2Frun_every.h;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=0d4c538577971f032f5d5575c9521fa963429b59;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/dmclock/support/src/run_every.h b/src/ceph/src/dmclock/support/src/run_every.h deleted file mode 100644 index 0d4c538..0000000 --- a/src/ceph/src/dmclock/support/src/run_every.h +++ /dev/null @@ -1,70 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Copyright (C) 2017 Red Hat Inc. - */ - - -#pragma once - -#include -#include -#include -#include -#include - -namespace crimson { - using std::chrono::duration_cast; - using std::chrono::milliseconds; - - // runs a given simple function object waiting wait_period - // milliseconds between; the destructor stops the other thread - // immediately - class RunEvery { - using Lock = std::unique_lock; - using Guard = std::lock_guard; - using TimePoint = std::chrono::steady_clock::time_point; - - bool finishing = false; - std::chrono::milliseconds wait_period; - std::function body; - std::mutex mtx; - std::condition_variable cv; - - // put threads last so all other variables are initialized first - - std::thread thd; - - public: - -#ifdef ADD_MOVE_SEMANTICS - RunEvery(); -#endif - - template - RunEvery(D _wait_period, - std::function _body) : - wait_period(duration_cast(_wait_period)), - body(_body) - { - thd = std::thread(&RunEvery::run, this); - } - - RunEvery(const RunEvery& other) = delete; - RunEvery& operator=(const RunEvery& other) = delete; - RunEvery(RunEvery&& other) = delete; -#ifdef ADD_MOVE_SEMANTICS - RunEvery& operator=(RunEvery&& other); -#else - RunEvery& operator=(RunEvery&& other) = delete; -#endif - - ~RunEvery(); - - void join(); - - protected: - - void run(); - }; -}