diff options
author | max42 <max42@yandex-team.com> | 2023-06-30 11:13:34 +0300 |
---|---|---|
committer | max42 <max42@yandex-team.com> | 2023-06-30 11:13:34 +0300 |
commit | 3e1899838408bbad47622007aa382bc8a2b01f87 (patch) | |
tree | 0f21c1e6add187ddb6c3ccc048a7d640ce03fb87 /library/cpp/threading/cron/cron.cpp | |
parent | 5463eb3f5e72a86f858a3d27c886470a724ede34 (diff) | |
download | ydb-3e1899838408bbad47622007aa382bc8a2b01f87.tar.gz |
Revert "YT-19324: move YT provider to ydb/library/yql"
This reverts commit ca272f12fdd0e8d5c3e957fc87939148f1caaf72, reversing
changes made to 49f8acfc8b0b5c0071b804423bcf53fda26c7c12.
Diffstat (limited to 'library/cpp/threading/cron/cron.cpp')
-rw-r--r-- | library/cpp/threading/cron/cron.cpp | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/library/cpp/threading/cron/cron.cpp b/library/cpp/threading/cron/cron.cpp deleted file mode 100644 index e7c1c59735..0000000000 --- a/library/cpp/threading/cron/cron.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "cron.h" - -#include <library/cpp/deprecated/atomic/atomic.h> - -#include <util/system/thread.h> -#include <util/system/event.h> - -using namespace NCron; - -namespace { - struct TPeriodicHandle: public IHandle { - inline TPeriodicHandle(TJob job, TDuration interval, const TString& threadName) - : Job(job) - , Interval(interval) - , Done(false) - { - TThread::TParams params(DoRun, this); - if (!threadName.empty()) { - params.SetName(threadName); - } - Thread = MakeHolder<TThread>(params); - Thread->Start(); - } - - static inline void* DoRun(void* data) noexcept { - ((TPeriodicHandle*)data)->Run(); - - return nullptr; - } - - inline void Run() noexcept { - while (true) { - Job(); - - Event.WaitT(Interval); - - if (AtomicGet(Done)) { - return; - } - } - } - - ~TPeriodicHandle() override { - AtomicSet(Done, true); - Event.Signal(); - Thread->Join(); - } - - TJob Job; - TDuration Interval; - TManualEvent Event; - TAtomic Done; - THolder<TThread> Thread; - }; -} - -IHandlePtr NCron::StartPeriodicJob(TJob job) { - return NCron::StartPeriodicJob(job, TDuration::Seconds(0), ""); -} - -IHandlePtr NCron::StartPeriodicJob(TJob job, TDuration interval) { - return NCron::StartPeriodicJob(job, interval, ""); -} - -IHandlePtr NCron::StartPeriodicJob(TJob job, TDuration interval, const TString& threadName) { - return new TPeriodicHandle(job, interval, threadName); -} - -IHandle::~IHandle() = default; |