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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user