Module: Mize
- Extended by:
- Configure
- Defined in:
- lib/mize.rb,
lib/mize/configure.rb,
lib/mize/global_clear.rb,
lib/mize/memoize.rb,
lib/mize/railtie.rb,
lib/mize/version.rb
Overview
Version information for the Mize gem.
This module is auto-generated by GemHadar and exposes the
current release version as a set of constants. Do not edit it
by hand; it is rewritten on every rake version invocation.
Defined Under Namespace
Modules: CacheMethods, CacheProtocol, Configure, Memoize, Reload Classes: DefaultCache, Railtie
Constant Summary collapse
- MUTEX =
Process-wide lock guarding all cache and wrapping mutations.
Every operation that mutates shared Mize state (+memoize+,
Mize.cache_clear,Mize::Reload#reload) serialises on this mutex, so the toolkit is safe to use from multiple threads. Mutex.new
- VERSION =
The current version of the Mize gem as a String.
'0.7.0'- VERSION_ARRAY =
:nodoc:
VERSION.split('.').map(&:to_i)
- VERSION_MAJOR =
:nodoc:
VERSION_ARRAY[0]
- VERSION_MINOR =
:nodoc:
VERSION_ARRAY[1]
- VERSION_BUILD =
:nodoc:
VERSION_ARRAY[2]
Class Attribute Summary collapse
-
.wrapped ⇒ Object
Bookkeeping of already-wrapped targets.
Class Method Summary collapse
-
.cache_clear ⇒ Mize
Clear all memoization caches at once.
-
.each_cache {|cache| ... } ⇒ Mize
private
Yield every live
Mize::CacheProtocolobject to the block. -
.synchronize { ... } ⇒ Object
Acquire the global Mize mutex for the duration of
block.
Class Attribute Details
.wrapped ⇒ Object
Bookkeeping of already-wrapped targets.
Maps [module, method_id, function] => [freeze, store_nil] so that
duplicate memoize calls can be detected and conflicting options
rejected. Cleared on Mize::Reload#reload.
33 34 35 |
# File 'lib/mize.rb', line 33 def wrapped @wrapped end |
Class Method Details
.cache_clear ⇒ Mize
Clear all memoization caches at once.
Walks every live Mize::CacheProtocol instance in the process (see
each_cache) and invokes clear on each, inside Mize.synchronize so
the sweep is atomic with respect to concurrent reads/writes.
11 12 13 |
# File 'lib/mize/global_clear.rb', line 11 def cache_clear each_cache(&:clear) end |
.each_cache {|cache| ... } ⇒ Mize (private)
Yield every live Mize::CacheProtocol object to the block.
The sweep runs under Mize.synchronize so it cannot observe a
half-cleared cache. Objects only appear here because they
include Mize::CacheProtocol.
25 26 27 28 29 30 31 32 |
# File 'lib/mize/global_clear.rb', line 25 def each_cache Mize.synchronize do for cache in ObjectSpace.each_object(Mize::CacheProtocol) yield cache end end self end |
.synchronize { ... } ⇒ Object
Acquire the global Mize mutex for the duration of block.
Exposes the internal MUTEX under a stable API so callers can make
a sequence of memoized calls atomic with respect to other threads:
The hot path (individual memoized calls) is lock-free by design; use this when you need the check→compute→write cycle to be indivisible.
MRI forbids Mutex#synchronize from a trap context (signal handlers
and GC finalizers), raising +ThreadError: can't be called from trap
context+. This is an intentional, still-current design decision (see
DevMeeting-2025-07-10 on
https://bugs.ruby-lang.org/issues/19473), not a bug being patched, so
this method rescues that specific error and runs block without the
lock rather than raising into a finalizer. Other +ThreadError+s (e.g.
recursive locking) are re-raised.
60 61 62 63 64 65 66 67 68 |
# File 'lib/mize.rb', line 60 def synchronize(&block) MUTEX.synchronize(&block) rescue ThreadError => e if e..include?("trap context") block.() else raise e end end |