@@ -40,11 +40,13 @@ use datafusion_proto::physical_plan::AsExecutionPlan;
4040use futures:: FutureExt ;
4141use log:: { debug, error, info, warn} ;
4242use std:: any:: Any ;
43+ use std:: cell:: LazyCell ;
4344use std:: convert:: TryInto ;
4445use std:: error:: Error ;
4546use std:: sync:: mpsc:: { Receiver , Sender , TryRecvError } ;
4647use std:: time:: { SystemTime , UNIX_EPOCH } ;
4748use std:: { sync:: Arc , time:: Duration } ;
49+ use tokio:: sync:: oneshot:: Sender as OneShotSender ;
4850use tokio:: sync:: { OwnedSemaphorePermit , Semaphore } ;
4951use tonic:: transport:: Channel ;
5052
@@ -60,6 +62,7 @@ pub async fn poll_loop<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan>
6062 mut scheduler : SchedulerGrpcClient < Channel > ,
6163 executor : Arc < Executor > ,
6264 codec : BallistaCodec < T , U > ,
65+ readiness : Option < OneShotSender < String > > ,
6366) -> Result < ( ) , BallistaError > {
6467 let executor_specification: ExecutorSpecification = executor
6568 . metadata
@@ -78,6 +81,13 @@ pub async fn poll_loop<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan>
7881 let dedicated_executor =
7982 DedicatedExecutor :: new ( "task_runner" , executor_specification. task_slots as usize ) ;
8083
84+ let report_ready = LazyCell :: new ( || {
85+ if let Some ( chan) = readiness {
86+ chan. send ( executor. metadata . id . clone ( ) )
87+ . expect ( "Must send readiness" )
88+ }
89+ } ) ;
90+
8191 loop {
8292 // Wait for task slots to be available before asking for new work
8393 let permit = available_task_slots. acquire ( ) . await . unwrap ( ) ;
@@ -100,6 +110,8 @@ pub async fn poll_loop<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan>
100110 } )
101111 . await ;
102112
113+ * report_ready;
114+
103115 match poll_work_result {
104116 Ok ( result) => {
105117 let PollWorkResult {
0 commit comments