本文整理汇总了C++中parser_t::jobs方法的典型用法代码示例。如果您正苦于以下问题:C++ parser_t::jobs方法的具体用法?C++ parser_t::jobs怎么用?C++ parser_t::jobs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser_t
的用法示例。
在下文中一共展示了parser_t::jobs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find_job_by_name
/// It should search the job list for something matching the given proc.
static bool find_job_by_name(const wchar_t *proc, std::vector<job_id_t> &ids,
const parser_t &parser) {
bool found = false;
for (const auto &j : parser.jobs()) {
if (j->command_is_empty()) continue;
if (match_pid(j->command(), proc)) {
if (!contains(ids, j->job_id)) {
// If pids doesn't already have the pgid, add it.
ids.push_back(j->job_id);
}
found = true;
}
// Check if the specified pid is a child process of the job.
for (const process_ptr_t &p : j->processes) {
if (p->actual_cmd.empty()) continue;
if (match_pid(p->actual_cmd, proc)) {
if (!contains(ids, j->job_id)) {
// If pids doesn't already have the pgid, add it.
ids.push_back(j->job_id);
}
found = true;
}
}
}
return found;
}
示例2: all_jobs_finished
static bool all_jobs_finished(const parser_t &parser) {
for (const auto &j : parser.jobs()) {
// If any job is not completed, return false.
// If there are stopped jobs, they are ignored.
if (j->is_constructed() && !j->is_completed() && !j->is_stopped()) {
return false;
}
}
return true;
}
示例3: wait_for_backgrounds
static int wait_for_backgrounds(parser_t &parser, bool any_flag) {
size_t jobs_len = parser.jobs().size();
while ((!any_flag && !all_jobs_finished(parser)) ||
(any_flag && !any_jobs_finished(jobs_len, parser))) {
if (reader_test_interrupted()) {
return 128 + SIGINT;
}
proc_wait_any(parser);
}
return 0;
}
示例4: any_jobs_finished
static bool any_jobs_finished(size_t jobs_len, const parser_t &parser) {
bool no_jobs_running = true;
// If any job is removed from list, return true.
if (jobs_len != parser.jobs().size()) {
return true;
}
for (const auto &j : parser.jobs()) {
// If any job is completed, return true.
if (j->is_constructed() && (j->is_completed() || j->is_stopped())) {
return true;
}
// Check for jobs running exist or not.
if (j->is_constructed() && !j->is_stopped()) {
no_jobs_running = false;
}
}
if (no_jobs_running) {
return true;
}
return false;
}
示例5: get_job_id_from_pid
/// Return the job id to which the process with pid belongs.
/// If a specified process has already finished but the job hasn't, parser_t::job_get_from_pid()
/// doesn't work properly, so use this function in wait command.
static job_id_t get_job_id_from_pid(pid_t pid, const parser_t &parser) {
for (const auto &j : parser.jobs()) {
if (j->pgid == pid) {
return j->job_id;
}
// Check if the specified pid is a child process of the job.
for (const process_ptr_t &p : j->processes) {
if (p->pid == pid) {
return j->job_id;
}
}
}
return 0;
}