mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27:49 +08:00
[md] general threading rules put into a separate subsection
This commit is contained in:
parent
0026234429
commit
c8a4438de4
@ -22,7 +22,7 @@
|
||||
* [Plugin Configuration File](plugin_configuration_file.html)
|
||||
* [Plugin Dependencies](plugin_dependencies.html)
|
||||
* [Architectural Overview](architectural_overview.html)
|
||||
* [General Threading Rules](TODO)
|
||||
* [General Threading Rules](general_threading_rules.html)
|
||||
* [Virtual Files](TODO)
|
||||
* [Documents](TODO)
|
||||
* [PSI Files](TODO)
|
||||
|
@ -17,7 +17,7 @@ and then return to this document.
|
||||
|
||||
This topic covers the following subjects:
|
||||
|
||||
* General Threading Rules
|
||||
* [General Threading Rules](general_threading_rules.html)
|
||||
|
||||
* Virtual Files
|
||||
|
||||
@ -29,15 +29,6 @@ This topic covers the following subjects:
|
||||
|
||||
* Psi Elements
|
||||
|
||||
## General Threading Rules
|
||||
|
||||
In general, the data structures of IntelliJ IDEA are covered by a single "multiple readers / single writer" lock.
|
||||
Reading data is allowed from any thread.
|
||||
Reading data from the UI thread does not require any special effort, however, read operations performed from any other thread need to be wrapped in a read action by using ```ApplicationManager.getApplication().runReadAction()```.
|
||||
Writing the data is only allowed from the UI thread, and write operations always need to be wrapped in a write action with ```ApplicationManager.getApplication().runWriteAction()```.
|
||||
|
||||
To pass control from a background thread to the event dispatch thread, instead of the standard ```SwingUtilities.invokeLater()```, plugins should use ```ApplicationManager.getApplication().invokeLater()```. The latter API allows to specify the _modality state_ for the call - the stack of modal dialogs under which the call is allowed to execute. Passing ```ModalityState.NON_MODAL``` means that the operation will be executed after all modal dialogs are closed, and passing ```ModalityState.stateForComponent()``` means that the operation may be executed while the specified component (part of a dialog) is still visible.
|
||||
|
||||
## Virtual Files
|
||||
|
||||
A virtual file
|
||||
|
13
general_threading_rules.md
Normal file
13
general_threading_rules.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
layout: editable
|
||||
title: General Threading Rules
|
||||
---
|
||||
|
||||
In general, the data structures of IntelliJ IDEA are covered by a single "multiple readers / single writer" lock.
|
||||
Reading data is allowed from any thread.
|
||||
Reading data from the UI thread does not require any special effort, however, read operations performed from any other thread need to be wrapped in a read action by using ```ApplicationManager.getApplication().runReadAction()```.
|
||||
Writing the data is only allowed from the UI thread, and write operations always need to be wrapped in a write action with ```ApplicationManager.getApplication().runWriteAction()```.
|
||||
|
||||
To pass control from a background thread to the event dispatch thread, instead of the standard ```SwingUtilities.invokeLater()```, plugins should use ```ApplicationManager.getApplication().invokeLater()```.
|
||||
The latter API allows to specify the _modality state_ for the call - the stack of modal dialogs under which the call is allowed to execute.
|
||||
Passing ```ModalityState.NON_MODAL``` means that the operation will be executed after all modal dialogs are closed, and passing ```ModalityState.stateForComponent()``` means that the operation may be executed while the specified component (part of a dialog) is still visible.
|
Loading…
x
Reference in New Issue
Block a user