Skip to content

Commit

Permalink
Change cores to jobs in the code as well
Browse files Browse the repository at this point in the history
  • Loading branch information
samoht committed Jan 7, 2013
1 parent 078f652 commit 9271600
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/client/opamSolution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,9 @@ let apply_solution ?(force = false) t sol =
| [h] -> OpamPackage.to_string h
| l -> OpamPackage.Set.to_string (OpamPackage.Set.of_list l) in

let cores = OpamFile.Config.cores t.config in
let jobs = OpamFile.Config.jobs t.config in
try
PackageActionGraph.Parallel.parallel_iter cores sol.to_process ~pre ~child ~post;
PackageActionGraph.Parallel.parallel_iter jobs sol.to_process ~pre ~child ~post;
OK
with PackageActionGraph.Parallel.Errors (errors, remaining) ->
OpamGlobals.msg "\n";
Expand Down
28 changes: 18 additions & 10 deletions src/core/opamFile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ module Config = struct
opam_version : opam_version ;
repositories : repository_name list ;
switch : switch;
cores : int;
jobs : int;
}
let with_repositories t repositories = { t with repositories }
Expand All @@ -434,23 +434,25 @@ module Config = struct
let opam_version t = t.opam_version
let repositories t = t.repositories
let switch t = t.switch
let cores t = t.cores
let jobs t = t.jobs
let create opam_version switch repositories cores =
{ opam_version ; repositories ; switch ; cores }
let create opam_version switch repositories jobs =
{ opam_version ; repositories ; switch ; jobs }
let empty = {
opam_version = OpamVersion.of_string OpamGlobals.opam_version;
repositories = [];
switch = OpamSwitch.of_string "<empty>";
cores = OpamGlobals.default_cores;
jobs = OpamGlobals.default_jobs;
}
let s_repositories = "repositories"
let s_switch = "switch"
let s_switch1 = "alias"
let s_switch2 = "ocaml-version"
let s_jobs = "jobs"
let s_cores = "cores"
let s_system_version1 = "system_ocaml-version"
Expand All @@ -460,14 +462,15 @@ module Config = struct
s_opam_version;
s_repositories;
s_switch;
s_cores;
s_jobs;
(* this fields are no longer useful, but we keep it for backward
compatibility *)
s_switch1;
s_switch2;
s_system_version1;
s_system_version2;
s_cores;
]
let of_string filename f =
Expand Down Expand Up @@ -516,10 +519,15 @@ module Config = struct
| Some v, _ , _
| _ , Some v, _
| _ , _ , Some v -> v
| None , None , None -> OpamGlobals.error_and_exit "No current switch defined" in
| None , None , None -> OpamGlobals.error_and_exit "No current switch defined." in
let cores = OpamFormat.assoc s.file_contents s_cores OpamFormat.parse_int in
{ opam_version; repositories; switch; cores }
let jobs =
let mk str = OpamFormat.assoc_option s.file_contents str OpamFormat.parse_int in
match mk s_jobs, mk s_cores with
| Some i, _ -> i
| _ , Some i -> i
| _ -> 1 in
{ opam_version; repositories; switch; jobs }
let to_string filename t =
let s = {
Expand All @@ -530,7 +538,7 @@ module Config = struct
OpamFormat.make_list
(OpamRepositoryName.to_string |> OpamFormat.make_string)
t.repositories);
Variable (s_cores , OpamFormat.make_int t.cores);
Variable (s_jobs , OpamFormat.make_int t.jobs);
Variable (s_switch, OpamFormat.make_string (OpamSwitch.to_string t.switch))
]
} in
Expand Down
4 changes: 2 additions & 2 deletions src/core/opamFile.mli
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ module Config: sig
(** Return the OCaml switch *)
val switch: t -> switch

(** Return the number of cores *)
val cores: t -> int
(** Return the number of jobs *)
val jobs: t -> int

end

Expand Down
2 changes: 1 addition & 1 deletion src/core/opamGlobals.ml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ let makecmd = ref (lazy (
| _ -> "make"
)
)
let default_cores = 1
let default_jobs = 1

let exit i =
raise (Exit i)

0 comments on commit 9271600

Please sign in to comment.