aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/neh/jobqueue.h
diff options
context:
space:
mode:
authormonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
committermonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
commit06e5c21a835c0e923506c4ff27929f34e00761c2 (patch)
tree75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /library/cpp/neh/jobqueue.h
parent03f024c4412e3aa613bb543cf1660176320ba8f4 (diff)
downloadydb-06e5c21a835c0e923506c4ff27929f34e00761c2.tar.gz
fix ya.make
Diffstat (limited to 'library/cpp/neh/jobqueue.h')
-rw-r--r--library/cpp/neh/jobqueue.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/library/cpp/neh/jobqueue.h b/library/cpp/neh/jobqueue.h
new file mode 100644
index 00000000000..ec86458cf05
--- /dev/null
+++ b/library/cpp/neh/jobqueue.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include <library/cpp/coroutine/engine/impl.h>
+
+#include <util/generic/yexception.h>
+#include <util/stream/output.h>
+
+namespace NNeh {
+ class IJob {
+ public:
+ inline void operator()(TCont* c) noexcept {
+ try {
+ DoRun(c);
+ } catch (...) {
+ Cdbg << "run " << CurrentExceptionMessage() << Endl;
+ }
+ }
+
+ virtual ~IJob() {
+ }
+
+ private:
+ virtual void DoRun(TCont* c) = 0;
+ };
+
+ class IJobQueue {
+ public:
+ template <class T>
+ inline void Schedule(T req) {
+ ScheduleImpl(req.Get());
+ Y_UNUSED(req.Release());
+ }
+
+ virtual void ScheduleImpl(IJob* job) = 0;
+
+ virtual ~IJobQueue() {
+ }
+ };
+
+ IJobQueue* JobQueue();
+}