mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Added a dedicated panic channel.
This commit is contained in:
parent
a7c885706e
commit
cfb066ef20
13 changed files with 108 additions and 232 deletions
|
@ -17,11 +17,16 @@ static HOOK_SET: Once = ONCE_INIT;
|
|||
/// TLS data pertaining to how failures should be reported
|
||||
pub struct PanicHandlerLocal {
|
||||
/// failure handler passed through spawn_named_with_send_on_failure
|
||||
pub fail: Box<(FnBox(&(Any + Send))) + Send + 'static>
|
||||
pub fail: Box<FnBox(&Any)>
|
||||
}
|
||||
|
||||
thread_local!(pub static LOCAL_INFO: RefCell<Option<PanicHandlerLocal>> = RefCell::new(None));
|
||||
|
||||
/// Set the thread-local panic hook
|
||||
pub fn set_thread_local_hook(local: Box<FnBox(&Any)>) {
|
||||
LOCAL_INFO.with(|i| *i.borrow_mut() = Some(PanicHandlerLocal { fail: local }));
|
||||
}
|
||||
|
||||
/// Initiates the custom panic hook
|
||||
/// Should be called in main() after arguments have been parsed
|
||||
pub fn initiate_panic_hook() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue