1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Modified by Longbridge for gpui-fast.
//! Tracks whether the app's [`AppCell`] is currently borrowed, so platform
//! code that can run re-entrantly from a nested message pump can defer its
//! work instead of panicking on a second `borrow_mut`.
//!
//! On Windows, creating a WebView2 pumps the thread's message queue
//! synchronously (`webview2_com::wait_with_pump`). If GPUI has already
//! dispatched a task message — a foreground task, a timer — that nested
//! dispatch runs `AsyncApp::update`, which calls `AppCell::borrow_mut` while
//! the outer operation (e.g. `Window::draw`) still holds the borrow, and the
//! process panics with `RefCell already borrowed`.
use RefCell;
use ;
use crateAppCell;
thread_local!
/// Records the app's [`AppCell`] for this thread. Called once from the
/// platform launch callback in `Application::run`/`run_embedded`.
pub
/// Whether the app on this thread currently holds any borrow of its
/// [`AppCell`]. A shared borrow counts: `borrow_mut` fails on both.
///
/// Platform message handlers that can run re-entrantly while the app is
/// borrowed must check this before touching the app and defer their work
/// (e.g. by queueing the message) rather than calling `borrow_mut`.