diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /third_party/rust/interrupt-support | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/interrupt-support')
6 files changed, 29 insertions, 3 deletions
diff --git a/third_party/rust/interrupt-support/.cargo-checksum.json b/third_party/rust/interrupt-support/.cargo-checksum.json index 052b3da11a..89a260dc6e 100644 --- a/third_party/rust/interrupt-support/.cargo-checksum.json +++ b/third_party/rust/interrupt-support/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"c2ca168a6ba35961681f351e010d21696d8779ddac06436338431bd39ed16ebb","README.md":"7f1418b4a7c138ba20bcaea077fe6cf0d6ffbaf6df6b90c80efc52aa0d0e2e9f","src/error.rs":"b83cbe8abd22a9d687508d236a2a77e28b3fc6c39673633e5820cc0e3fc86cba","src/interruptee.rs":"c56f9ac610d0b24a128a907266432287558c4b73f6c24b82674ca7894181d18f","src/lib.rs":"cf44a84310913be5264e1c4a3e004a9f7a6cd82d01a109bb6ac4d6002b5dd560","src/shutdown.rs":"b9dfdb717932301035001a0398967384f1b993e14505860415d023febbe82d63","src/sql.rs":"7e050313884a281e6b3fc7a4514374e08cb9e5f3c5aefb873be92e56f30af660"},"package":null}
\ No newline at end of file +{"files":{"Cargo.toml":"f31bc542c5a3e5dfe82a7c62fa4a0a3e5b56424b77eb7ad913aa322e5e070c60","README.md":"7f1418b4a7c138ba20bcaea077fe6cf0d6ffbaf6df6b90c80efc52aa0d0e2e9f","build.rs":"49840f26c73c5db19cb4e7f02930e49d7a19648168b83f2313ac1a0303c103df","src/error.rs":"b83cbe8abd22a9d687508d236a2a77e28b3fc6c39673633e5820cc0e3fc86cba","src/interrupt_support.udl":"5472e585280576de4fab587278e6e24cc26a7c74e0489aeef3c41671c768f662","src/interruptee.rs":"c56f9ac610d0b24a128a907266432287558c4b73f6c24b82674ca7894181d18f","src/lib.rs":"cf44a84310913be5264e1c4a3e004a9f7a6cd82d01a109bb6ac4d6002b5dd560","src/shutdown.rs":"881a358b053fdd01b56b59864547b6456625dea4ee311b2e0ed3762009516ce6","src/sql.rs":"ba04479f740a25310fd171a473b9870580ad9f02bb2f1109c0171694cad4c2cd"},"package":null}
\ No newline at end of file diff --git a/third_party/rust/interrupt-support/Cargo.toml b/third_party/rust/interrupt-support/Cargo.toml index ced41d7c4e..78dfc448f9 100644 --- a/third_party/rust/interrupt-support/Cargo.toml +++ b/third_party/rust/interrupt-support/Cargo.toml @@ -20,6 +20,7 @@ license = "MPL-2.0" [dependencies] lazy_static = "1.4" parking_lot = ">=0.11,<=0.12" +uniffi = "0.27.1" [dependencies.rusqlite] version = "0.30.0" @@ -29,3 +30,7 @@ features = [ "bundled", "unlock_notify", ] + +[build-dependencies.uniffi] +version = "0.27.1" +features = ["build"] diff --git a/third_party/rust/interrupt-support/build.rs b/third_party/rust/interrupt-support/build.rs new file mode 100644 index 0000000000..20533b7a2f --- /dev/null +++ b/third_party/rust/interrupt-support/build.rs @@ -0,0 +1,8 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +fn main() { + uniffi::generate_scaffolding("./src/interrupt_support.udl").unwrap(); +} 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 + } +} |