@@ -627,6 +627,10 @@ def to_s
627627 attach_function :vips_vector_set_enabled , [ :int ] , :void
628628 attach_function :vips_vector_isenabled , [ ] , :int
629629 attach_function :vips_concurrency_set , [ :int ] , :void
630+ attach_function :vips_concurrency_get , [ ] , :int
631+
632+ # Track the original default concurrency so we can reset to it.
633+ DEFAULT_CONCURRENCY = vips_concurrency_get
630634
631635 # vips_foreign_get_suffixes was added in libvips 8.8
632636 begin
@@ -721,10 +725,23 @@ def self.cache_drop_all # :nodoc:
721725 vips_cache_drop_all
722726 end
723727
724- # Set the size of the libvips worker pool. This defaults to the number of
725- # hardware threads on your computer. Set to 1 to disable threading.
728+ # Get the size of libvips worker pools. Defaults to the VIPS_CONCURRENCY env
729+ # var or the number of hardware threads on your computer.
730+ def self . concurrency
731+ vips_concurrency_get
732+ end
733+
734+ # Get the default size of libvips worker pools.
735+ def self . concurrency_default
736+ DEFAULT_CONCURRENCY
737+ end
738+
739+ # Set the size of each libvips worker pool. Max 1024 threads. Set to 1 to
740+ # disable threading. Set to 0 or nil to reset to default.
726741 def self . concurrency_set n
742+ n = DEFAULT_CONCURRENCY if n . to_i == 0
727743 vips_concurrency_set n
744+ concurrency
728745 end
729746
730747 # Whether SIMD and the run-time compiler are enabled. This can give a nice
0 commit comments