com.h3c.util.concurrent

## Interface CriticalSectionExecutor

- All Known Implementing Classes:
    LockCriticalSectionExecutor, SemaphoreCriticalSectionExecutor

      public interface CriticalSectionExecutor

  Provides a simple but useful abstraction for controlling (Locking) access by multiple processes to a common resource in a parallel programming or multi-user environment.

  This interface abstract the underlying mechanism used for synchronization: Locks, Semaphores, distributed coordination (for distributed critical sections), etc.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `execute(Instruction instruction)` Executes a set of instructions as critical section (Mutual excluded).
    `void` | `execute(Instruction instruction, javax.measure.Measurable<javax.measure.quantity.Duration> timeout)` Executes a set of instructions as critical section (Mutual excluded).
    `<T> T` | `execute(Procedure<T> procedure)` Executes a procedure as critical section (Mutual excluded).
    `<T> T` | `execute(Procedure<T> procedure, javax.measure.Measurable<javax.measure.quantity.Duration> timeout)` Executes a procedure as critical section (Mutual excluded).

- - ### Method Detail

    - #### execute

          void execute(Instruction instruction)

      Executes a set of instructions as critical section (Mutual excluded).
      Parameters:
        `instruction` - instruction to execute

    - #### execute

          void execute(Instruction instruction,
                     javax.measure.Measurable<javax.measure.quantity.Duration> timeout)
                       throws TimeoutException

      Executes a set of instructions as critical section (Mutual excluded).
      Parameters:
        `instruction` - instruction to execute
        `timeout` - the maximum time to wait, null to wait indefinitely
      Throws:
        `TimeoutException` - if the operation times out

    - #### execute

          <T> T execute(Procedure<T> procedure)

      Executes a procedure as critical section (Mutual excluded).
      Parameters:
        `procedure` - procedure to execute
      Returns:
        the procedure result

    - #### execute

          <T> T execute(Procedure<T> procedure,
                      javax.measure.Measurable<javax.measure.quantity.Duration> timeout)
                    throws TimeoutException

      Executes a procedure as critical section (Mutual excluded).
      Parameters:
        `procedure` - procedure to execute
        `timeout` - the maximum time to wait, null to wait indefinitely
      Returns:
        the procedure result
      Throws:
        `TimeoutException` - if the operation times out

Copyright © 2014. All Rights Reserved.