mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-28 09:33:01 +00:00
base: relax thread::spawn_with_timeout trait reqs.
base:🧵:spawn_with_timeout was stricter than std:🧵:spawn, which wasn't really helpful. (In prod code we use std:🧵:spawn, so being stricter than that isn't useful or safer in a meaningful way.) BUG=b:276361599 TEST=builds Change-Id: I4197d3ac082af4077f82d7d70a11869b0a886238 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556841 Reviewed-by: Richard Zhang <rizhang@google.com> Commit-Queue: Noah Gold <nkgold@google.com>
This commit is contained in:
parent
738220a623
commit
70e9e588d1
1 changed files with 2 additions and 3 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
use std::any::Any;
|
||||
use std::panic;
|
||||
use std::panic::UnwindSafe;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use std::thread;
|
||||
|
@ -15,13 +14,13 @@ use std::time::Duration;
|
|||
pub fn spawn_with_timeout<F, T>(f: F) -> JoinHandleWithTimeout<T>
|
||||
where
|
||||
F: FnOnce() -> T,
|
||||
F: Send + UnwindSafe + 'static,
|
||||
F: Send + 'static,
|
||||
T: Send + 'static,
|
||||
{
|
||||
// Use a channel to signal completion to the join handle
|
||||
let (tx, rx) = channel();
|
||||
let handle = thread::spawn(move || {
|
||||
let val = panic::catch_unwind(f);
|
||||
let val = panic::catch_unwind(panic::AssertUnwindSafe(f));
|
||||
tx.send(()).unwrap();
|
||||
val
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue