File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -11,14 +11,15 @@ pub(crate) struct JobToken {
1111 /// The token can either be a fresh token obtained from the jobserver or - if `token` is None - an implicit token for this process.
1212 /// Both are valid values to put into queue.
1313 token : Option < Acquired > ,
14- pool : Sender < Option < Acquired > > ,
15- should_return_to_queue : bool ,
14+ /// A pool to which `token` should be returned. `pool` is optional, as one might want to release a token straight away instead
15+ /// of storing it back in the pool - see [`Self::forget()`] function for that.
16+ pool : Option < Sender < Option < Acquired > > > ,
1617}
1718
1819impl Drop for JobToken {
1920 fn drop ( & mut self ) {
20- if self . should_return_to_queue {
21- let _ = self . pool . send ( self . token . take ( ) ) ;
21+ if let Some ( pool ) = & self . pool {
22+ let _ = pool. send ( self . token . take ( ) ) ;
2223 }
2324 }
2425}
@@ -29,7 +30,7 @@ impl JobToken {
2930 /// which is a correct thing to do once it is known that there won't be
3031 /// any more token acquisitions.
3132 pub ( crate ) fn forget ( & mut self ) {
32- self . should_return_to_queue = false ;
33+ self . pool . take ( ) ;
3334 }
3435}
3536
@@ -69,8 +70,7 @@ impl JobTokenServer {
6970 } ;
7071 JobToken {
7172 token,
72- pool : self . tx . clone ( ) ,
73- should_return_to_queue : true ,
73+ pool : Some ( self . tx . clone ( ) ) ,
7474 }
7575 }
7676}
You can’t perform that action at this time.
0 commit comments