Extract CPU counting to doom-num-cpus function
And improves macOS support as discussed in hlissner/doom-emacs@db6a27c
This commit is contained in:
parent
b49c40bbb3
commit
b91a1b3e7b
3 changed files with 22 additions and 13 deletions
|
@ -40,3 +40,21 @@ Warning: freezes indefinitely on any stdin prompt."
|
|||
(sit-for 0.1))
|
||||
(process-exit-status process))
|
||||
(string-trim (buffer-string)))))
|
||||
|
||||
(defvar doom-num-cpus nil)
|
||||
;;;###autoload
|
||||
(defun doom-num-cpus ()
|
||||
"Return the max number of processing units on this system.
|
||||
Tries to be portable. Returns 1 if cannot be determined."
|
||||
(or doom-num-cpus
|
||||
(setq doom-num-cpus
|
||||
(max
|
||||
1 (cond ((eq 'windows-nt system-type)
|
||||
(or (ignore-errors
|
||||
(string-to-number (getenv "NUMBER_OF_PROCESSORS")))
|
||||
1))
|
||||
((executable-find "nproc")
|
||||
(string-to-number (cdr (doom-call-process "nproc"))))
|
||||
((and IS-MAC (executable-find "sysctl"))
|
||||
(string-to-number (cdr (doom-call-process "sysctl" "-n" "hw.ncpu"))))
|
||||
(t 1))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue