Rename general_threading_rules.md to threading_model.md

This commit is contained in:
Karol Lewandowski 2024-07-30 15:58:50 +02:00
parent 3573443830
commit 5c77f0e8f9
29 changed files with 38 additions and 38 deletions

View File

@ -65,7 +65,7 @@
<toc-element topic="fundamentals.md" accepts-web-file-names="reference_guide.html,architectural_overview.html">
<toc-element toc-title="Component Model"/>
<toc-element topic="disposers.md"/>
<toc-element topic="general_threading_rules.md">
<toc-element topic="threading_model.md" accepts-web-file-names="general-threading-rules.html">
<toc-element topic="background_processes.md"/>
</toc-element>
<toc-element topic="kotlin_coroutines.md">

View File

@ -74,7 +74,7 @@ NOTE: Entries not starting with code quotes (`name`) can be added to document no
### IntelliJ Platform 2023.3
Threading Model changes
: Please see updated [](general_threading_rules.md).
: Please see updated [](threading_model.md).
Removal of commons-lang2 and commons-collections libraries
: _commons-lang2_ library is going to be removed, a temporary compatibility layer (marked with `@Deprecated(forRemoval = true)` to highlight usages) is bundled.

View File

@ -28,7 +28,7 @@ Specifying Threading for Actions
: Implementations of `AnAction` need to override `getActionUpdateThread()` as detailed in [](basic_action_system.md#principal-implementation-overrides).
Threading assertions in tests
: All rules for [threading](general_threading_rules.md) are now checked in tests as well.
: All rules for [threading](threading_model.md) are now checked in tests as well.
Mapping New UI icons
: See [](icons.md#new-ui-icons) on how to provide additional icons.

View File

@ -13,7 +13,7 @@ _Early Access Program_ (EAP) releases of upcoming versions are available [here](
### IntelliJ Platform 2023.3
Threading Model changes
: Please see updated [](general_threading_rules.md).
: Please see updated [](threading_model.md).
External Annotators in Dumb Mode
: [](syntax_highlighting_and_error_highlighting.md#external-annotator) can now run in during indexing.

View File

@ -53,7 +53,7 @@ Cached Values and Dumb Mode
: Note change for [](psi_performance.md#projectRootManagerDependency).
Saving Settings on background thread
: Saving project/application [settings](settings.md) is no longer performed on [EDT](general_threading_rules.md) to avoid freezes. [Issue](https://youtrack.jetbrains.com/issue/IJPL-127/Save-project-application-settings-on-background-thread)
: Saving project/application [settings](settings.md) is no longer performed on [EDT](threading_model.md) to avoid freezes. [Issue](https://youtrack.jetbrains.com/issue/IJPL-127/Save-project-application-settings-on-background-thread)
### IntelliJ IDEA 2024.1

View File

@ -50,7 +50,7 @@ Document Object Model _(DOM)_
## E
Event Dispatch Thread _(EDT)_
: The [Event Dispatch Thread](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html) handles all Swing events. See also [](general_threading_rules.md) and [](coroutine_dispatchers.md#edt-dispatcher).
: The [Event Dispatch Thread](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html) handles all Swing events. See also [](threading_model.md) and [](coroutine_dispatchers.md#edt-dispatcher).
Extension Point _(EP)_
: Most functionality is provided by [Using Extension Points](plugin_extensions.md) provided by the platform or plugins. Plugins can also [define their own](plugin_extension_points.md) to allow extensibility.
@ -101,7 +101,7 @@ JetBrains Runtime _(JBR)_
## N
Non-Blocking Read Action _(NBRA)_
: A &rarr;&nbsp;_Read Action_ that is canceled by a &rarr;&nbsp;_Write Action_. See also [](general_threading_rules.md#read-action-cancellability).
: A &rarr;&nbsp;_Read Action_ that is canceled by a &rarr;&nbsp;_Write Action_. See also [](threading_model.md#read-action-cancellability).
## P
@ -115,7 +115,7 @@ Program Structure Interface _(PSI)_
## R
Read Action _(RA)_
: Allows accessing code-related data structures for reading purposes. See also [](general_threading_rules.md).
: Allows accessing code-related data structures for reading purposes. See also [](threading_model.md).
&rarr;&nbsp;_Non-Blocking Read Action_ &rarr;&nbsp;_Write Action_
Run Configuration _(RC)_
@ -156,7 +156,7 @@ Virtual File System _(VFS)_
## W
Write Action _(WA)_
: Allows accessing code-related data structures for writing purposes. See also [](general_threading_rules.md).
: Allows accessing code-related data structures for writing purposes. See also [](threading_model.md).
&rarr;&nbsp;_Read Action_
Write Allowing Read Action _(WARA)_

View File

@ -29,7 +29,7 @@ The key classes are:
There are many `ProgressIndicator` implementations and the most commonly used are:
- [`EmptyProgressIndicator`](%gh-ic%/platform/core-api/src/com/intellij/openapi/progress/EmptyProgressIndicator.java) invisible (ignores text/fraction-related methods), used only for cancellation tracking.
Remembers its creation [modality state](general_threading_rules.md#invoking-operations-on-edt-and-modality).
Remembers its creation [modality state](threading_model.md#invoking-operations-on-edt-and-modality).
- [`ProgressIndicatorBase`](%gh-ic%/platform/analysis-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorBase.java) invisible but can be made visible by subclassing.
Stores text/fraction and allows retrieving them and possibly show in the UI.
Non-modal by default.

View File

@ -58,7 +58,7 @@ suspend fun readDataFromFile(): Data {
## EDT Dispatcher
The [`Dispatchers.EDT`](%gh-ic%/platform/core-api/src/com/intellij/openapi/application/coroutines.kt) dispatcher is used for executing UI actions on the Swing Event Dispatch Thread.
`Dispatchers.EDT` dispatches onto EDT within the context [modality state](general_threading_rules.md#invoking-operations-on-edt-and-modality).
`Dispatchers.EDT` dispatches onto EDT within the context [modality state](threading_model.md#invoking-operations-on-edt-and-modality).
### `Dispatchers.Main` vs. `Dispatchers.EDT`

View File

@ -16,8 +16,8 @@
the Threading section:
</p>
<list>
<li><a href="general_threading_rules.md#readers-writer-lock">Read-Write Lock</a></li>
<li><a href="general_threading_rules.md#read-action-cancellability">Read Action Cancellability</a></li>
<li><a href="threading_model.md#readers-writer-lock">Read-Write Lock</a></li>
<li><a href="threading_model.md#read-action-cancellability">Read Action Cancellability</a></li>
</list>
<p>This section explains running read actions (RA) in coroutines specifically.</p>
@ -69,7 +69,7 @@
<code>Application.runReadAction</code>
</a>
and similar methods (without any prefix/suffix) perform RA blocking WA, whereas RA allowing WA are invoked via
the <a href="general_threading_rules.md#read-action-cancellability"><code>NonBlockingReadAction</code> API</a>.
the <a href="threading_model.md#read-action-cancellability"><code>NonBlockingReadAction</code> API</a>.
</p>
<p>Be careful when migrating the code running read actions to coroutines.</p>
</warning>

View File

@ -145,7 +145,7 @@ suspend fun doSomething() {
## Changing Modality State
Avoid [changing modality state](general_threading_rules.md#invoking-operations-on-edt-and-modality) in the middle of a running coroutine:
Avoid [changing modality state](threading_model.md#invoking-operations-on-edt-and-modality) in the middle of a running coroutine:
```kotlin
cs.launch {

View File

@ -48,7 +48,7 @@ To create a `Document` instance that isn't bound to anything, use [`EditorFactor
## What are the rules of working with documents?
The general read/write action rules are in effect (see [](general_threading_rules.md)).
The general read/write action rules are in effect (see [](threading_model.md)).
Besides, any operations which modify the contents of the document must be wrapped in a command ([`CommandProcessor.executeCommand()`](%gh-ic%/platform/core-api/src/com/intellij/openapi/command/CommandProcessor.java)).
`executeCommand()` calls can be nested, and the outermost `executeCommand()` call is added to the undo stack.
If multiple documents are modified within a command, undoing this command will, by default, show a confirmation dialog to the user.

View File

@ -4,7 +4,7 @@
<link-summary>Performance tips on working with PSI.</link-summary>
See also [](general_threading_rules.md#avoiding-ui-freezes) and [](indexing_and_psi_stubs.md#improving-indexing-performance).
See also [](threading_model.md#avoiding-ui-freezes) and [](indexing_and_psi_stubs.md#improving-indexing-performance).
> [IDE Perf](https://plugins.jetbrains.com/plugin/15104-ide-perf) plugin provides on-the-fly performance diagnostic tools, including a dedicated view for [`CachedValue`](#cache-results-of-heavy-computations) metrics.

View File

@ -55,7 +55,7 @@ As explained in [Overriding the `AnAction.update()` Method](#overriding-the-ana
<primary-label ref="2022.3"/>
`AnAction.getActionUpdateThread()` returns an [`ActionUpdateThread`](%gh-ic%/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionUpdateThread.java),
which specifies if the `update()` method is called on a [background thread (BGT) or the event-dispatching thread (EDT)](general_threading_rules.md).
which specifies if the `update()` method is called on a [background thread (BGT) or the event-dispatching thread (EDT)](threading_model.md).
The preferred method is to run the update on the BGT, which has the advantage of guaranteeing application-wide read access to
[PSI](psi.md), [the virtual file system](virtual_file_system.md) (VFS), or [project models](project_structure.md).
Actions that run the update session on the BGT should not access the Swing component hierarchy directly.

View File

@ -66,7 +66,7 @@ Implement `DumbAware` to indicate activity can run in background thread (in para
: [`StartupActivity.Background`](%gh-ic%/platform/core-api/src/com/intellij/openapi/startup/StartupActivity.kt) for execution with a 5-second delay in background thread (2019.3 or later).
Any long-running or CPU intensive tasks should be made visible to users by using `ProgressManager.run(Task.Backgroundable)`.
Access to indexes must be wrapped with [`DumbService`](indexing_and_psi_stubs.md#dumb-mode), see also [General Threading Rules](general_threading_rules.md).
Access to indexes must be wrapped with [`DumbService`](indexing_and_psi_stubs.md#dumb-mode), see also [General Threading Rules](threading_model.md).
See also [](ide_infrastructure.md#running-tasks-once).

View File

@ -282,7 +282,7 @@ Registration in <path>plugin.xml</path>:
{style="warning" title="Correct Service Retrieval"}
Getting a service doesn't need a read action and can be performed from any thread.
If a service is requested from several [threads](general_threading_rules.md), it will be initialized in the first thread, and other threads will be blocked until it is fully initialized.
If a service is requested from several [threads](threading_model.md), it will be initialized in the first thread, and other threads will be blocked until it is fully initialized.
<tabs group="languages">
<tab title="Java" group-key="java">

View File

@ -51,7 +51,7 @@ To reproduce and understand problems in production, use [logging](ide_infrastruc
Even if a plugin works correctly and looks pleasing, poor performance will impact user satisfaction.
Slow highlighting, code completion, code generation, and other features may break the user's workflow and cause frustration leading to plugin uninstallation.
Always try to follow the performance tips described on the relevant topic pages, e.g., [](psi_performance.md), [](general_threading_rules.md#avoiding-ui-freezes), [](indexing_and_psi_stubs.md#improving-indexing-performance).
Always try to follow the performance tips described on the relevant topic pages, e.g., [](psi_performance.md), [](threading_model.md#avoiding-ui-freezes), [](indexing_and_psi_stubs.md#improving-indexing-performance).
Making as much functionality as possible working during [dumb mode](indexing_and_psi_stubs.md#dumb-mode) can also improve perceived performance.

View File

@ -68,7 +68,7 @@ The synchronous flag simply means that the calling thread will be blocked until
Both synchronous and asynchronous refreshes can be initiated from any thread.
If a refresh is initiated from a background thread, the calling thread must not hold a read action, because otherwise, a deadlock would occur.
See [IntelliJ Platform Architectural Overview](general_threading_rules.md) for more details on the threading model and read/write actions.
See [IntelliJ Platform Architectural Overview](threading_model.md) for more details on the threading model and read/write actions.
The same threading requirements also apply to functions like [`LocalFileSystem.refreshAndFindFileByPath()`](%gh-ic%/platform/analysis-api/src/com/intellij/openapi/vfs/LocalFileSystem.java), which perform a partial refresh if the file with the specified path is not found in the snapshot.
@ -78,7 +78,7 @@ If there is some code that needs to be executed after the refresh is complete, t
* [`RefreshQueue.createSession()`](%gh-ic%/platform/analysis-api/src/com/intellij/openapi/vfs/newvfs/RefreshQueue.java)
* [`VirtualFile.refresh()`](%gh-ic%/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java)
In some cases, synchronous refreshes can cause deadlocks, depending on which [locks](general_threading_rules.md#readers-writer-lock) are held by the thread invoking the refresh operation.
In some cases, synchronous refreshes can cause deadlocks, depending on which [locks](threading_model.md#readers-writer-lock) are held by the thread invoking the refresh operation.
## Virtual File System Events

View File

@ -17,7 +17,7 @@ See [GitHub Changelog](https://github.com/JetBrains/intellij-sdk-docs/commits/ma
Threading Model
:
Revamp the [Threading Model](general_threading_rules.md) page (formerly _General Threading Rules_) and add a new page describing [background processes](background_processes.md), including cancellation and progress tracking.
Revamp the [Threading Model](threading_model.md) page (formerly _General Threading Rules_) and add a new page describing [background processes](background_processes.md), including cancellation and progress tracking.
### June
{june-24}
@ -105,7 +105,7 @@ Inlay Hints
: Update [](inlay_hints.md) page with the information about new APIs.
Threading Model
: Update [](general_threading_rules.md) to reflect changes in 2023.3 platform.
: Update [](threading_model.md) to reflect changes in 2023.3 platform.
Minor Changes and Additions
:
@ -461,7 +461,7 @@ Plugin Repository moved
{#july-19}
New page: Optimizing Performance
: Optimizing performance when [working with PSI](psi_performance.md), [during indexing](indexing_and_psi_stubs.md#improving-indexing-performance), and [](general_threading_rules.md#avoiding-ui-freezes).
: Optimizing performance when [working with PSI](psi_performance.md), [during indexing](indexing_and_psi_stubs.md#improving-indexing-performance), and [](threading_model.md#avoiding-ui-freezes).
### May
{#may-19}

View File

@ -8,5 +8,5 @@ This section describes the low-level fundamental building blocks of the IntelliJ
* The component model - how the application is hosted and composed. Lifetime and dependency management.
* [Disposers](disposers.md) - managing object lifetimes and resource cleanup
* [Threading models](general_threading_rules.md)
* [Threading models](threading_model.md)
* [Messaging](messaging_infrastructure.md)

View File

@ -33,7 +33,7 @@ See also [](#recognizing-complex-multi-block-expressions).
#### "Heavy" Brace Matching
<primary-label ref="2022.3"/>
If the brace matching is "too heavy" and should not be executed in [EDT](general_threading_rules.md), implement
If the brace matching is "too heavy" and should not be executed in [EDT](threading_model.md), implement
[`HeavyBraceHighlighter`](%gh-ic%/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HeavyBraceHighlighter.java)
and register in `com.intellij.heavyBracesHighlighter` extension point.

View File

@ -32,7 +32,7 @@ See also [](websymbols.md).
## Lifecycle
The `Symbol` instance is expected to stay valid within a single [read action](general_threading_rules.md), which means it's safe to pass the instance to different APIs.
The `Symbol` instance is expected to stay valid within a single [read action](threading_model.md), which means it's safe to pass the instance to different APIs.
A `Symbol` instance should not be referenced between read actions.
One should create a pointer via `Symbol.createPointer()` in the current read action, and then call `Pointer.dereference()` to obtain a `Symbol` instance in the subsequent read action.

View File

@ -102,7 +102,7 @@ myPanel.add(browser.getComponent());
#### Loading Documents
To load a document in the browser, use one of [`JBCefBrowserBase.load*()`](%gh-ic%/platform/platform-api/src/com/intellij/ui/jcef/JBCefBrowserBase.java) methods.
Methods loading documents can be called from both [EDT and background threads](general_threading_rules.md).
Methods loading documents can be called from both [EDT and background threads](threading_model.md).
It is possible to set an initial URL (passed to constructor or builder) that will be loaded when browser is created and initialized.
### Browser Client

View File

@ -66,7 +66,7 @@ Messages.showInfoMessage(roots.toString(), "Library Info");
### Creating a Library
To create a library, perform the following steps:
* Get a [write action](general_threading_rules.md#write-actions)
* Get a [write action](threading_model.md#write-actions)
* Obtain the library table to which you want to add the library. Use one of the following, depending on the library level:
* `LibraryTablesRegistrar.getInstance().getLibraryTable()`
* `LibraryTablesRegistrar.getInstance().getLibraryTable(Project)`
@ -80,13 +80,13 @@ You can find an example of using these APIs in the [project_model](%gh-sdk-sampl
### Adding Contents or Modifying a Library
To add or change the roots of a library, you need to perform the following steps:
* Get a [write action](general_threading_rules.md#write-actions)
* Get a [write action](threading_model.md#write-actions)
* Get a **modifiable model** for the library, using `Library.getModifiableModel()`
* Use methods such as `Library.ModifiableModel.addRoot()` to perform the necessary changes
* Commit the model using `Library.ModifiableModel.commit()`.
### Adding a Library Dependency to a Module
Use `ModuleRootModificationUtil.addDependency(Module, Library)` from under a [write action](general_threading_rules.md#write-actions).
Use `ModuleRootModificationUtil.addDependency(Module, Library)` from under a [write action](threading_model.md#write-actions).
### Checking Belonging to a Library
The [`ProjectFileIndex`](%gh-ic%/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java) interface implements a number of methods you can use to check whether the specified file belongs to the project library classes or library sources.

View File

@ -109,7 +109,7 @@ See [SDK](sdk.md) for more details.
Utility classes used for modifying the project structure can be found in the package [`projectModel-impl.openapi`](%gh-ic%/platform/projectModel-impl/src/com/intellij/openapi).
Its [`roots`](%gh-ic%/platform/projectModel-impl/src/com/intellij/openapi/roots) subpackage contains instances and utilities intended for work with project and module source roots, including [`ModuleRootModificationUtil`](%gh-ic%/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleRootModificationUtil.java) and [`ProjectRootUtil`](%gh-ic%/platform/projectModel-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java).
Project structure changes need to be performed in [write action](general_threading_rules.md#write-actions).
Project structure changes need to be performed in [write action](threading_model.md#write-actions).
Refer to the [project_model](%gh-sdk-samples-master%/project_model/src/main/java/org/intellij/sdk/project/model/ModificationAction.java) code sample to learn how project structure modification can be implemented.

View File

@ -164,7 +164,7 @@ If the above does not show a preview, there could be further problems of the fol
Example: [`DeleteMultiCatchFix.getFileModifierForPreview()`](%gh-ic%/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteMultiCatchFix.java)
Be careful, as there could be subclasses. Better play safe and declare your action/fix class as final.
3. `invoke()`/`applyFix()` starts a write action. If `startsInWriteAction()` returns `true`, then this is unnecessary, and you can remove the write action.
4. `invoke()`/`applyFix()` asserts (directly or indirectly) that it is invoked in the dispatch thread or inside a write action (see also [](general_threading_rules.md)).
4. `invoke()`/`applyFix()` asserts (directly or indirectly) that it is invoked in the dispatch thread or inside a write action (see also [](threading_model.md)).
The preview is applied in a background thread without a write action as it works on non-physical elements.
You may consider removing these assertions or keeping them only if the preview is not active (use `IntentionPreviewUtils.isIntentionPreviewActive()`).
5. `PsiDocumentManager.getDocument(psiFile)` is used which isn't supported for a non-physical `psiFile`.

View File

@ -23,4 +23,4 @@ The following are referenced in the tutorial:
**Related topics:**
* [](basic_action_system.md)
* [](general_threading_rules.md)
* [](threading_model.md)

View File

@ -119,7 +119,7 @@ Selection information is measured in terms of [Offset](coordinates_system.md#car
Text replacement could be done by calling the `Document` object's `replaceString()` method.
However, safely replacing the text requires the `Document` to be locked and any changes performed in a write action.
See the [Threading Issues](general_threading_rules.md) section to learn more about synchronization issues and changes safety on the IntelliJ Platform.
See the [Threading Issues](threading_model.md) section to learn more about synchronization issues and changes safety on the IntelliJ Platform.
This example changes the document within a [`WriteCommandAction`](%gh-ic%/platform/core-api/src/com/intellij/openapi/command/WriteCommandAction.java).
The complete `EditorIllustrationAction.actionPerformed()` method is shown below:

View File

@ -76,7 +76,7 @@ To show and hide a tool window dynamically while the user is working with the pr
For toolwindows shown only after invoking specific actions, use [`ToolWindowManager.registerToolWindow(String,RegisterToolWindowTaskBuilder)`](%gh-ic%/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.kt).
Always use [`ToolWindowManager.invokeLater()`](%gh-ic%/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.kt) instead of "plain" `Application.invokeLater()` when scheduling EDT tasks related to tool windows (see [](general_threading_rules.md)).
Always use [`ToolWindowManager.invokeLater()`](%gh-ic%/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.kt) instead of "plain" `Application.invokeLater()` when scheduling EDT tasks related to tool windows (see [](threading_model.md)).
## Contents (Tabs)