Lock Order Rule
- General Rule: Acquire all locks in a fixed order
- Eclipse Architecture
* Locking of Eclipse workspace resources comes first. * Other Locks * Locking of User Interface comes last (refer to the next paragraph).
- 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.
User Interface Lock Rule
- General Rule: Never block the User Interface thread.
- 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
- 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.