@@ -36,19 +36,22 @@ use datafusion_proto::physical_plan::AsExecutionPlan;
3636use futures:: FutureExt ;
3737use log:: { debug, error, info, warn} ;
3838use std:: any:: Any ;
39+ use std:: cell:: LazyCell ;
3940use std:: convert:: TryInto ;
4041use std:: error:: Error ;
4142use std:: ops:: Deref ;
4243use std:: sync:: mpsc:: { Receiver , Sender , TryRecvError } ;
4344use std:: time:: { SystemTime , UNIX_EPOCH } ;
4445use std:: { sync:: Arc , time:: Duration } ;
46+ use tokio:: sync:: oneshot:: Sender as OneShotSender ;
4547use tokio:: sync:: { OwnedSemaphorePermit , Semaphore } ;
4648use tonic:: transport:: Channel ;
4749
4850pub async fn poll_loop < T : ' static + AsLogicalPlan , U : ' static + AsExecutionPlan > (
4951 mut scheduler : SchedulerGrpcClient < Channel > ,
5052 executor : Arc < Executor > ,
5153 codec : BallistaCodec < T , U > ,
54+ readiness : Option < OneShotSender < String > > ,
5255) -> Result < ( ) , BallistaError > {
5356 let executor_specification: ExecutorSpecification = executor
5457 . metadata
@@ -67,6 +70,13 @@ pub async fn poll_loop<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan>
6770 let dedicated_executor =
6871 DedicatedExecutor :: new ( "task_runner" , executor_specification. task_slots as usize ) ;
6972
73+ let report_ready = LazyCell :: new ( || {
74+ if let Some ( chan) = readiness {
75+ chan. send ( executor. metadata . id . clone ( ) )
76+ . expect ( "Must send readiness" )
77+ }
78+ } ) ;
79+
7080 loop {
7181 // Wait for task slots to be available before asking for new work
7282 let permit = available_task_slots. acquire ( ) . await . unwrap ( ) ;
@@ -89,6 +99,8 @@ pub async fn poll_loop<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan>
8999 } )
90100 . await ;
91101
102+ * report_ready;
103+
92104 match poll_work_result {
93105 Ok ( result) => {
94106 let PollWorkResult {
0 commit comments