caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Cross-platform cpu count
@ 2011-09-02  0:04 Daniel Bünzli
  2011-09-02  0:38 ` malc
  2011-09-02  7:51 ` Richard W.M. Jones
  0 siblings, 2 replies; 11+ messages in thread
From: Daniel Bünzli @ 2011-09-02  0:04 UTC (permalink / raw)
  To: caml-list

Hello,

Can anybody confirm me that the following code works on cygwin :

let cpu_count () =
  try match Sys.os_type with
  | "Win32" -> int_of_string (Sys.getenv "NUMBER_OF_PROCESSORS")
  | _ ->
      let i = Unix.open_process_in "getconf _NPROCESSORS_ONLN" in
      let close () = ignore (Unix.close_process_in i) in
      try Scanf.fscanf i "%d" (fun n -> close (); n) with e -> close (); raise e
  with
  | Not_found | Sys_error _ | Failure _ | Scanf.Scan_failure _
  | End_of_file | Unix.Unix_error (_, _, _) -> 1

Thanks,

Daniel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-09-02 14:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-02  0:04 [Caml-list] Cross-platform cpu count Daniel Bünzli
2011-09-02  0:38 ` malc
2011-09-02  0:47   ` Daniel Bünzli
2011-09-02  7:39   ` David Allsopp
2011-09-02 10:03     ` Daniel Bünzli
2011-09-02 12:51     ` malc
2011-09-02 13:05       ` David Allsopp
2011-09-02 13:42         ` malc
2011-09-02  7:51 ` Richard W.M. Jones
2011-09-02  8:19   ` David Allsopp
2011-09-02 14:58     ` Richard W.M. Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).