1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-09-27 14:25:11 +00:00

allow contexts to specify accepted jobs

using a glob expression, the same way jobs can specify
contexts. This allows more flexibility in situations where
there are many jobs sharing limited contexts because it
may obviate the need to create a conf file for each job.

resolves #124
This commit is contained in:
Oliver Giles
2020-11-13 13:47:02 +13:00
parent bd489bdbb0
commit 4fb95fcb4f
4 changed files with 60 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
///
/// Copyright 2015-2019 Oliver Giles
/// Copyright 2015-2020 Oliver Giles
///
/// This file is part of Laminar
///
@@ -19,16 +19,10 @@
#ifndef LAMINAR_CONTEXT_H_
#define LAMINAR_CONTEXT_H_
#include <fnmatch.h>
#include <string>
#include <set>
class Run;
// FNM_EXTMATCH isn't supported under musl
#if !defined(FNM_EXTMATCH)
#define FNM_EXTMATCH 0
#endif
// Represents a context within which a Run will be executed. Allows applying
// a certain environment to a set of Jobs, or setting a limit on the number
// of parallel Runs
@@ -39,17 +33,7 @@ public:
std::string name;
int numExecutors;
int busyExecutors = 0;
bool canQueue(std::set<std::string>& patterns) {
if(busyExecutors >= numExecutors)
return false;
for(std::string pattern : patterns) {
if(fnmatch(pattern.c_str(), name.c_str(), FNM_EXTMATCH) == 0)
return true;
}
return false;
}
std::set<std::string> jobPatterns;
};