File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,16 +16,22 @@ pub fn run(args: SamplyArgs) -> Result<()> {
1616 let argv = std:: iter:: once ( std:: ffi:: OsString :: from ( "samply" ) ) . chain ( args. args ) ;
1717 let opt = cli:: Opt :: parse_from ( argv) ;
1818
19- match opt. action {
20- #[ cfg( any(
21- target_os = "android" ,
22- target_os = "macos" ,
23- target_os = "linux" ,
24- target_os = "windows"
25- ) ) ]
26- cli:: Action :: Record ( a) => :: samply:: do_record_action ( a) ,
27- _ => unimplemented ! ( "Only `samply record` is supported" ) ,
28- }
19+ // samply spins up its own tokio runtime internally, so it must run on a
20+ // thread that isn't already inside our `#[tokio::main]` runtime.
21+ std:: thread:: scope ( |s| {
22+ s. spawn ( || match opt. action {
23+ #[ cfg( any(
24+ target_os = "android" ,
25+ target_os = "macos" ,
26+ target_os = "linux" ,
27+ target_os = "windows"
28+ ) ) ]
29+ cli:: Action :: Record ( a) => :: samply:: do_record_action ( a) ,
30+ _ => unimplemented ! ( "Only `samply record` is supported" ) ,
31+ } )
32+ . join ( )
33+ . map_err ( |_| anyhow:: anyhow!( "samply thread panicked" ) )
34+ } ) ?;
2935
3036 Ok ( ( ) )
3137}
You can’t perform that action at this time.
0 commit comments