summaryrefslogtreecommitdiffstats
path: root/third_party/rust/interrupt-support/src
diff options
context:
space:
mode:
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
+ }
+}