Commit for Maxim <3
[build.git] / src / job-server.h
blob2e83607a90f19648293a9687f0e1b89bb36b9d18
1 /* job-server.c -- declarations of list-based job-server routines.
3 Copyright (C) 2022 Sergey Sushilin <sergeysushilin@protonmail.com>
5 This file is part of Build.
7 Build is free software: you can redistribute it and/or
8 modify it under the terms of either the GNU General Public License
9 as published by the Free Software Foundation;
10 either version 2 of the License, or version 3 of the License,
11 or both in parallel, as here.
13 Build is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received copies of the GNU General Public License
19 version 2 and 3 along with this program.
20 If not, see http://www.gnu.org/licenses/. */
22 #pragma once
24 #include "thread.h"
26 struct job
28 struct build_tree_branch *branch;
29 struct job *next;
32 struct job_list
34 struct mutex mutex;
35 struct
37 size_t count;
38 struct job *array;
39 } jobs;
40 size_t size;
41 struct job *first;
42 struct job *last;
45 typedef bool (*build_target_t) (const struct build_tree_branch *branch,
46 const Hash *rules,
47 struct quoting_slots *qs,
48 char **envp,
49 const Hash *tracked_files,
50 bool dryrun);
52 struct job_server
54 struct job_list job_list;
55 size_t n_threads;
56 struct thread *threads;
57 build_target_t routine;
58 const Hash *rules;
59 const Hash *tracked_files;
60 char **envp;
61 bool dryrun;
62 atomic_bool failed;
65 extern NODISCARD bool job_list_create_from_build_tree (struct job_list *job_list,
66 struct build_tree *tree)
67 NONNULL (1, 2);
68 extern NODISCARD bool job_server_initialize (struct job_server *job_server,
69 build_target_t routine,
70 size_t n_threads,
71 const Hash *restrict rules,
72 char **envp,
73 const Hash *restrict tracked_files,
74 bool dryrun)
75 NONNULL (1, 2, 4, 5) ACCESS (write_only, 1);
76 extern NODISCARD bool job_server_start (struct job_server *job_server)
77 NONNULL (1);
78 extern NODISCARD bool job_server_finalize (struct job_server *job_server)
79 NONNULL (1);