@@ -152,39 +152,18 @@ void TfBuilderDevice::InitTask()
152152 }
153153 }
154154
155- // start the task
156- if (!start ()) {
157- mShouldExit = true ;
158- throw std::runtime_error (" Aborting InitTask(). Cannot configure." );
159- }
160-
161- // wait for the memory allocation and registration to finish
162- lBuffersAllocatedFuture.wait ();
163- if (!lBuffersAllocatedFuture.get ()) {
164- EDDLOG (" InitTask::MemorySegment allocation failed. Exiting..." );
165- throw " InitTask::MemorySegment allocation failed. Exiting..." ;
166- return ;
167- }
168-
169- DDDLOG (" InitTask completed." );
170- }
171-
172- bool TfBuilderDevice::start ()
173- {
155+ // Connect all StfSender gRPCs
174156 while (!mRpc ->start (mTfDataRegionSize , mFlpInputHandler ->getStfRequestQueue (), mFlpInputHandler ->getDataQueue ())) {
175157 // check if should stop looking for TfScheduler
176158 if (mRpc ->isTerminateRequested ()) {
177- mShouldExit = true ;
178- return false ;
159+ return ;
179160 }
180161
181162 // try to reach the scheduler unless we should exit
182163 if (IsRunningState () && NewStatePending ()) {
183- mShouldExit = true ;
184- return false ;
164+ return ;
185165 }
186-
187- std::this_thread::sleep_for (1s);
166+ std::this_thread::sleep_for (250ms);
188167 }
189168
190169 // we reached the scheduler instance, initialize everything else
@@ -200,13 +179,23 @@ bool TfBuilderDevice::start()
200179 // start file sink
201180 mFileSink .start ();
202181
203- // Start input handlers
182+ // wait for the memory allocation and registration to finish
183+ lBuffersAllocatedFuture.wait ();
184+ if (!lBuffersAllocatedFuture.get ()) {
185+ EDDLOG (" InitTask::MemorySegment allocation failed. Exiting..." );
186+ throw std::runtime_error (" InitTask::MemorySegment allocation failed. Exiting..." );
187+ }
188+
189+ // Start input handlers after the memory is finished allocating
204190 if (!mFlpInputHandler ->start ()) {
205- mShouldExit = true ;
206- EDDLOG (" Could not initialize input connections. Exiting." );
207- return false ;
191+ throw std::runtime_error (" Could not initialize input connections. Exiting." );
208192 }
209193
194+ DDDLOG (" InitTask completed." );
195+ }
196+
197+ bool TfBuilderDevice::start ()
198+ {
210199 return true ;
211200}
212201
0 commit comments