ri > Concurrent::SynchronizedDelegator

📛 NAME

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

🚀 Quick Reference

Use CaseCommandDescription
🛡️ Make an object thread-safeSynchronizedDelegator.new(array)Wraps the object with a coarse-grained monitor lock

📚 Class Methods

🔧 Instance Methods

Concurrent::SynchronizedDelegator
📛 NAME 🚀 Quick Reference 📚 Class Methods 🔧 Instance Methods

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)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format