1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-10-17 08:40:54 +00:00

resolves #30: job execution timeout

Add the ability to configure a timeout in seconds
after which a job run will be automatically aborted
This commit is contained in:
Oliver Giles
2018-05-12 13:25:19 +03:00
parent ce81be85c7
commit 649caee297
6 changed files with 37 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
///
/// Copyright 2015-2017 Oliver Giles
/// Copyright 2015-2018 Oliver Giles
///
/// This file is part of Laminar
///
@@ -469,6 +469,12 @@ void Server::addDescriptor(int fd, std::function<void(const char*,size_t)> cb) {
childTasks.add(handleFdRead(event, buffer.asPtr().begin(), cb).attach(std::move(event)).attach(std::move(buffer)));
}
kj::Promise<void> Server::addTimeout(int seconds, std::function<void ()> cb) {
return ioContext.lowLevelProvider->getTimer().afterDelay(seconds * kj::SECONDS).then([cb](){
cb();
}).eagerlyEvaluate(nullptr);
}
void Server::addWatchPath(const char* dpath) {
inotify_add_watch(inotify_fd, dpath, IN_ONLYDIR | IN_CLOSE_WRITE | IN_CREATE | IN_DELETE);
}