I spent the night working on some experiments. 1. AbstractRubyStruct and AtomicStruct
RubyStruct is an interesting data structure, since it has a fixed size declared when you define a new Struct. This makes it possible for us to implement more efficient access, among other things. More interesting, perhaps, is the fact that if we abstracted out the Ruby-facing Struct logic, we could implement an AtomicStruct that uses an AtomicReferenceArray for all entries. This would provide volatility out of the box, and with a few additional methods it would provide atomicity too. I made an attempt at such an experiment here: https://github.com/headius/jruby/tree/atomic_struct AtomicStruct has all the same methods as Struct, but the entries are volatile and it adds the following methods: * <entry name>_case - Atomic compare-and-swap of the entry's value. * <entry name>_swap - Atomic get-and-set of the entry's value. It is an interesting experiment. Thoughts? 2. AbstractRubyHash This is the long-talked-about refactoring of RubyHash into an abstract half and an implementation half. The experiment is here: https://github.com/headius/jruby/tree/abstract_hash It does not yet compile, but it creates a new abstract class AbstractRubyHash that contains nearly all the Ruby-facing logic. RubyHash then extends that and implements a set of abstract methods for our current Hash implementation. Once made to compile, this could be the basis for a set of Hash-lookalike classes that wrap any java.util.Map class, such as ConcurrentHashMap. That would be very powerful. Thoughts? - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email