summaryrefslogtreecommitdiffstats
path: root/third_party/rust/interrupt-support/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/interrupt-support/src
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/interrupt-support/src')
-rw-r--r--third_party/rust/interrupt-support/src/interrupt_support.udl5
-rw-r--r--third_party/rust/interrupt-support/src/shutdown.rs5
-rw-r--r--third_party/rust/interrupt-support/src/sql.rs7
3 files changed, 15 insertions, 2 deletions
diff --git a/third_party/rust/interrupt-support/src/interrupt_support.udl b/third_party/rust/interrupt-support/src/interrupt_support.udl
new file mode 100644
index 0000000000..06264fec0e
--- /dev/null
+++ b/third_party/rust/interrupt-support/src/interrupt_support.udl
@@ -0,0 +1,5 @@
+namespace interrupt_support {
+ // Enter shutdown mode, causing all current and future interruptable operations to be interrupted.
+ void shutdown();
+};
+
diff --git a/third_party/rust/interrupt-support/src/shutdown.rs b/third_party/rust/interrupt-support/src/shutdown.rs
index 9c64df27e8..88a56029b8 100644
--- a/third_party/rust/interrupt-support/src/shutdown.rs
+++ b/third_party/rust/interrupt-support/src/shutdown.rs
@@ -12,13 +12,14 @@ License, v. 2.0. If a copy of the MPL was not distributed with this
///
/// Here's how add shutdown support to a component:
///
-/// - Use `SqlInterruptScope::new_with_shutdown_check()` to create a new
-/// `SqlInterruptScope`
/// - Database connections need to be wrapped in a type that:
/// - Implements `AsRef<SqlInterruptHandle>`.
/// - Gets wrapped in an `Arc<>`. This is needed so the shutdown code can get a weak reference to
/// the instance.
/// - Calls `register_interrupt()` on creation
+/// - Use `SqlInterruptScope::begin_interrupt_scope()` before each operation.
+/// This will return an error if shutdown mode is in effect.
+/// The interrupt scope should be periodically checked to handle the operation being interrupted/shutdown after it started.
///
/// See `PlacesDb::begin_interrupt_scope()` and `PlacesApi::new_connection()` for an example of
/// how this works.
diff --git a/third_party/rust/interrupt-support/src/sql.rs b/third_party/rust/interrupt-support/src/sql.rs
index 6f361013fc..a9f10f8cf8 100644
--- a/third_party/rust/interrupt-support/src/sql.rs
+++ b/third_party/rust/interrupt-support/src/sql.rs
@@ -120,3 +120,10 @@ impl Interruptee for SqlInterruptScope {
self.was_interrupted()
}
}
+
+// Needed to allow Weak<SqlInterruptHandle> to be passed to `interrupt::register_interrupt`
+impl AsRef<SqlInterruptHandle> for SqlInterruptHandle {
+ fn as_ref(&self) -> &SqlInterruptHandle {
+ self
+ }
+}