Pave/Threading

From Eclipsepedia

Jump to: navigation, search

Contents

Lock Order Rule

  1. General Rule: Acquire all locks in a fixed order
  2. Eclipse Architecture
   * Locking of Eclipse workspace resources comes first.
   * Other Locks
   * Locking of User Interface comes last (refer to the next paragraph).
  1. Pattern generator behavior: In the pattern templates the Eclipse resource locks (ISchedulingRule) are acquired before any other kinds of synchronization such as Java monitors (synchronized). Define global order of all synchronizations.

PAVE THREADING.PNG

User Interface Lock Rule

  1. General Rule: Never block the User Interface thread.
  2. Eclipse Architecture: Access to display is protected by the User Interface thread (main thread). In this case the User Interface thread acts as a lock protecting the display.
   * Display.syncExec() : acquires the User Interface lock
   * ModalContext.run(): releases the User Interface lock
  1. Pattern generator behavior: The templates(The Data model operations ) are executed outside of the User Interface thread. Whenever the templates access the User Interface y calling Display.asyncExec they should not acquire User Interface locks.

Changing Threads Rule

   *  General Rule: Lock order includes synchronous work in other threads.
   * Pattern Generator Behavior: The template contributors should not try to escape the lock order by using another thread. The templates are not recommended to execute work synchronously in other threads, rather than they are executed directly in the same thread.

Subsequent Execution of Operations

Pattern Generation Framework is all about subsequent execution of operations, while in most cases the output of one operation will be input for the next operation. This is why it is really important to follow these guidelines:

   * Every operation should exit its execution method only when all processes started by it are finished.
   * Every operation that triggers Eclipse build should wait for all build processes to stop.