Class SynchronizedStatement

All Implemented Interfaces:
NodeMetaDataHandler

public class SynchronizedStatement extends Statement
Represents a synchronized statement that provides mutual exclusion for a code block. A synchronized statement acquires a lock on the monitor associated with the control expression before executing the code block, ensuring that only one thread can execute the synchronized block at a time for the given monitor object.
  • Constructor Details

    • SynchronizedStatement

      public SynchronizedStatement(Expression expression, Statement code)
      Constructs a synchronized statement with the given monitor expression and code block.
      Parameters:
      expression - the Expression that evaluates to the monitor object to synchronize on
      code - the Statement to execute under mutual exclusion
  • Method Details

    • getCode

      public Statement getCode()
      Returns the statement executed within the synchronized block.
      Returns:
      the Statement executed under mutual exclusion
    • setCode

      public void setCode(Statement statement)
      Sets the statement executed within the synchronized block.
      Parameters:
      statement - the Statement to execute under mutual exclusion
    • getExpression

      public Expression getExpression()
      Returns the monitor expression whose lock is acquired for synchronization.
      Returns:
      the monitor Expression
    • visit

      public void visit(GroovyCodeVisitor visitor)
      Description copied from class: ASTNode
      Accepts a code visitor for AST traversal and transformation. Subclasses must implement this method to support visitor pattern-based processing. The visitor pattern enables decoupling of AST structure from processing logic.
      Overrides:
      visit in class ASTNode
      Parameters:
      visitor - the GroovyCodeVisitor to process this node
    • setExpression

      public void setExpression(Expression expression)
      Sets the monitor expression whose lock is acquired for synchronization.
      Parameters:
      expression - the monitor Expression