Concurrent::SynchronizedDelegator < SimpleDelegator
This class provides a trivial way to synchronize all calls to a given object by wrapping it with a Delegator that performs Monitor#enter/exit calls around the delegated #send. Example:
array = [] # not thread-safe on many impls
array = SynchronizedDelegator.new([]) # thread-safe
A simple Monitor provides a very coarse-grained way to synchronize a given object, in that it will cause synchronization for methods that have no need for it, but this is a trivial way to get thread-safety where none may exist currently on some implementations.
This class is currently being considered for inclusion into stdlib, via https://bugs.ruby-lang.org/issues/8556
| Use Case | Command | Description |
|---|---|---|
| 🛡️ Make an object thread-safe | SynchronizedDelegator.new(array) | Wraps the object with a coarse-grained monitor lock |
new — Creates a new synchronized delegator wrapping the given objectmethod_missing — Delegates to the wrapped object, synchronizedsetup — (implementation detail)teardown — (implementation detail)Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-29 18:38 @216.73.216.177
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format