Skip to content

Commit f9f6d0e

Browse files
Merge release/1.18 into master
2 parents ec9a313 + 635ca37 commit f9f6d0e

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/fiber/execution_context.cr

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,16 @@ module Fiber::ExecutionContext
9292
# parallel execution context for example.
9393
#
9494
# Respects the `CRYSTAL_WORKERS` environment variable if present and valid,
95-
# and otherwise defaults to the minimum number of logical CPUs available to
96-
# the process or available on the computer.
95+
# and otherwise defaults to the number of logical CPUs available to the
96+
# process or on the computer.
9797
def self.default_workers_count : Int32
98-
if count = ENV["CRYSTAL_WORKERS"]?.try(&.to_i?)
99-
return count.clamp(1..)
100-
end
101-
102-
total = System.cpu_count.to_i.clamp(1..)
103-
effective = Crystal::System.effective_cpu_count.to_i.clamp(1..)
98+
count = ENV["CRYSTAL_WORKERS"]?.try(&.to_i?) || -1
99+
count = Crystal::System.effective_cpu_count.to_i if count == -1
100+
count = System.cpu_count.to_i if count == -1
104101
# TODO: query for CPU limits (e.g. linux/cgroup, freebsd/rctl, ...)
105102

106-
Math.min(total, effective)
103+
# always report at least 1 worker
104+
count.clamp(1..)
107105
end
108106

109107
# :nodoc:

src/io.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ abstract class IO
930930
# io.rewind
931931
# io.read_bytes(Int32, IO::ByteFormat::LittleEndian) # => 0x01020304
932932
# ```
933-
def read_bytes(type : T.class, format : IO::ByteFormat = IO::ByteFormat::SystemEndian) : T forall T
933+
def read_bytes(type, format : IO::ByteFormat = IO::ByteFormat::SystemEndian)
934934
type.from_io(self, format)
935935
end
936936

0 commit comments

Comments
 (0)