44use std:: {
55 ffi:: OsString ,
66 fmt, io,
7+ marker:: PhantomData ,
78 path:: PathBuf ,
89 process:: { ChildStderr , ChildStdout , Command , Stdio } ,
910} ;
1011
1112use command_group:: { CommandGroup , GroupChild } ;
12- use crossbeam_channel:: { unbounded , Receiver , Sender } ;
13+ use crossbeam_channel:: Sender ;
1314use stdx:: process:: streaming_output;
1415
1516/// Cargo output is structured as a one JSON per line. This trait abstracts parsing one line of
@@ -99,10 +100,10 @@ pub(crate) struct CommandHandle<T> {
99100/// a read syscall dropping and therefore terminating the process is our best option.
100101child : JodGroupChild ,
101102thread : stdx:: thread:: JoinHandle < io:: Result < ( bool , String ) > > ,
102- pub ( crate ) receiver : Receiver < T > ,
103103program : OsString ,
104104arguments : Vec < OsString > ,
105105current_dir : Option < PathBuf > ,
106+ _phantom : PhantomData < T > ,
106107}
107108
108109impl < T > fmt:: Debug for CommandHandle < T > {
@@ -116,7 +117,7 @@ impl<T> fmt::Debug for CommandHandle<T> {
116117}
117118
118119impl < T : ParseFromLine > CommandHandle < T > {
119- pub ( crate ) fn spawn ( mut command : Command ) -> std:: io:: Result < Self > {
120+ pub ( crate ) fn spawn ( mut command : Command , sender : Sender < T > ) -> std:: io:: Result < Self > {
120121 command. stdout ( Stdio :: piped ( ) ) . stderr ( Stdio :: piped ( ) ) . stdin ( Stdio :: null ( ) ) ;
121122let mut child = command. group_spawn ( ) . map ( JodGroupChild ) ?;
122123
@@ -127,13 +128,12 @@ impl<T: ParseFromLine> CommandHandle<T> {
127128let stdout = child. 0 . inner ( ) . stdout . take ( ) . unwrap ( ) ;
128129let stderr = child. 0 . inner ( ) . stderr . take ( ) . unwrap ( ) ;
129130
130- let ( sender, receiver) = unbounded ( ) ;
131131let actor = CargoActor :: < T > :: new ( sender, stdout, stderr) ;
132132let thread = stdx:: thread:: Builder :: new ( stdx:: thread:: ThreadIntent :: Worker )
133133. name ( "CommandHandle" . to_owned ( ) )
134134. spawn ( move || actor. run ( ) )
135135. expect ( "failed to spawn thread" ) ;
136- Ok ( CommandHandle { program, arguments, current_dir, child, thread, receiver } )
136+ Ok ( CommandHandle { program, arguments, current_dir, child, thread, _phantom : PhantomData } )
137137}
138138
139139pub ( crate ) fn cancel ( mut self ) {
0 commit comments