Class VariableAccessorField

java.lang.Object
org.jruby.runtime.ivars.VariableAccessorField

public final class VariableAccessorField extends Object
A lazy mechanism for accessing VariableAccessors for a given variable name.
  • Field Details

    • name

      private final String name
      the name of the variable
    • variableAccessor

      private volatile VariableAccessor variableAccessor
      the accessor cached after it has been allocated
  • Constructor Details

    • VariableAccessorField

      public VariableAccessorField(String name)
      Construct a new VariableAccessorField for the given named variable.
      Parameters:
      name - the name of the variable
  • Method Details

    • getVariableAccessorForRead

      public VariableAccessor getVariableAccessorForRead()
      Retrieve the variable accessor for read.
      Returns:
      the variable accessor appropriate for reads
    • getVariableAccessorForWrite

      public VariableAccessor getVariableAccessorForWrite(VariableTableManager tableMgr)
      Retrieve the variable access for write.
      Parameters:
      tableMgr - the VariableTableManager for which to allocate an accessor, if it has not already been allocated.
      Returns:
      the variable accessor appropriate for writes.
    • allocateVariableAccessor

      private VariableAccessor allocateVariableAccessor(VariableTableManager tableMgr)
      Retrieve or allocate the variable accessor for this variable. This version differs from getVariableAccessorForWrite only in its visibility and the fact that it is synchronized against this field to ensure volatile behavior of the variableAccessor field.
      Parameters:
      tableMgr - the VariableTableManager for which to allocate an accessor, if it has not already been allocated.
      Returns:
      the variable accessor appropriate for writes