Skip to content

Commit 5016025

Browse files
committed
Remove debug output
Signed-off-by: Michael X. Grey <grey@openrobotics.org>
1 parent eab1ab6 commit 5016025

File tree

8 files changed

+32
-79
lines changed

8 files changed

+32
-79
lines changed

src/builder/connect.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,20 @@ fn try_connect(connect: Connect, world: &mut World) -> OperationResult {
6767
return Ok(());
6868
}
6969

70-
println!("Connecting {:?} to {:?}", connect.original_target, connect.new_target);
71-
7270
let old_inputs = world.get_entity_mut(connect.original_target).or_broken()?
7371
.take::<SingleInputStorage>().or_broken()?
7472
.take();
7573

76-
dbg!(&old_inputs);
77-
7874
for input in old_inputs.into_iter() {
79-
dbg!(input);
8075
let mut input_mut = world.get_entity_mut(input).or_broken()?;
8176

8277
if let Some(mut target) = input_mut.get_mut::<SingleTargetStorage>() {
8378
target.set(connect.new_target);
84-
dbg!(&target);
8579
}
8680

8781
if let Some(mut targets) = input_mut.get_mut::<ForkTargetStorage>() {
8882
for target in &mut targets.0 {
8983
if *target == connect.original_target {
90-
dbg!(&target, connect.new_target);
9184
*target = connect.new_target;
9285
}
9386
}
@@ -96,7 +89,6 @@ fn try_connect(connect: Connect, world: &mut World) -> OperationResult {
9689
if let Some(mut targets) = input_mut.get_mut::<StreamTargetMap>() {
9790
for target in &mut targets.map {
9891
if *target == connect.original_target {
99-
dbg!(&target, connect.new_target);
10092
*target = connect.new_target;
10193
}
10294
}

src/chain.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -740,44 +740,42 @@ mod tests {
740740
let mut context = TestingContext::minimal_plugins();
741741

742742
let workflow = context.build_io_workflow(|scope, builder| {
743-
scope
744-
.input
745-
.chain(builder)
743+
scope.input.chain(builder)
744+
// (2.0, 2.0)
746745
.map_block(add)
747-
.map_block(print_debug(format!("line {}", line!())))
746+
// 4.0
748747
.then_scope::<_, ()>(ScopeSettings::default(), |scope, builder| {
749-
scope
750-
.input
751-
.chain(builder)
752-
.map_block(print_debug(format!("line {}", line!())))
748+
scope.input.chain(builder)
749+
// 4.0
753750
.fork_clone_zip((
754751
|chain: Chain<f64>| {
755-
chain
756-
.map_block(print_debug(format!("line {}", line!())))
757-
.map_block(|value|
752+
// 4.0
753+
chain.map_block(|value|
758754
WaitRequest {
759755
duration: Duration::from_secs_f64(value),
760756
value,
761757
}
762758
)
763-
.map_block(print_debug(format!("line {}", line!())))
764759
.map_async(wait)
765-
.map_block(print_debug(format!("line {}", line!())))
760+
// 4.0
766761
.connect(scope.terminate);
767762
},
768763
|chain: Chain<f64>| {
769-
chain
770-
.map_block(print_debug(format!("line {}", line!())))
771-
.map_block(|a| (a, a))
772-
.map_block(print_debug(format!("line {}", line!())))
764+
// 4.0
765+
chain.map_block(|a| (a, a))
766+
// (4.0, 4.0)
773767
.map_block(add)
774-
.map_block(print_debug(format!("line {}", line!())))
768+
// 8.0
775769
.connect(scope.terminate);
776770
}
777771
));
778772
})
773+
// This should be won by the 8.0 branch because it does not wait,
774+
// while the 4.0 branch should wait for 4.0s.
779775
.map_block(|a| (a, a))
776+
// (8.0, 8.0)
780777
.map_block(add)
778+
// 16.0
781779
.connect(scope.terminate);
782780
});
783781

@@ -793,10 +791,8 @@ mod tests {
793791
.with_update_count(100),
794792
);
795793

796-
dbg!(context.get_unhandled_errors());
797-
798-
dbg!(promise.peek());
799-
assert_eq!(promise.peek().available().copied(), Some(20.0));
794+
assert_eq!(promise.peek().available().copied(), Some(16.0));
795+
assert!(context.no_unhandled_errors());
800796
}
801797

802798
// #[test]

src/input.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ impl<'w> ManageInput for EntityMut<'w> {
186186
session: Entity,
187187
data: T,
188188
) -> Result<(), OperationError> {
189-
dbg!(self.id());
190189
let mut storage = self.get_mut::<InputStorage<T>>().or_broken()?;
191-
dbg!(session);
192190
storage.reverse_queue.insert(0, Input { session, data });
193191
Ok(())
194192
}

src/operation.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,7 @@ pub struct OperationCleanup<'a> {
337337
impl<'a> OperationCleanup<'a> {
338338

339339
pub fn clean(&mut self) {
340-
let Some(source_ref) = self.world.get_entity(self.source) else {
341-
dbg!(self.source);
342-
return;
343-
};
344-
// let Some(cleanup) = self.world.get::<OperationCleanupStorage>(self.source) else {
345-
// dbg!(self.source);
346-
// return;
347-
// };
348-
let Some(cleanup) = source_ref.get::<OperationCleanupStorage>() else {
349-
dbg!(self.source);
340+
let Some(cleanup) = self.world.get::<OperationCleanupStorage>(self.source) else {
350341
return;
351342
};
352343

@@ -379,14 +370,11 @@ impl<'a> OperationCleanup<'a> {
379370
}
380371

381372
pub fn notify_cleaned(&mut self) -> OperationResult {
382-
dbg!(self.source);
383373
let source_mut = self.world.get_entity_mut(self.source).or_broken()?;
384374
let scope = source_mut.get::<ScopeStorage>().or_not_ready()?.get();
385-
dbg!(scope);
386375
let mut scope_mut = self.world.get_entity_mut(scope).or_broken()?;
387376
let mut scope_contents = scope_mut.get_mut::<ScopeContents>().or_broken()?;
388377
if scope_contents.register_cleanup_of_node(self.session, self.source) {
389-
dbg!();
390378
self.roster.cleanup_finished(
391379
CleanupFinished { scope, session: self.session }
392380
);
@@ -588,7 +576,6 @@ impl<Op: Operation + 'static + Sync + Send> Command for AddOperation<Op> {
588576
}
589577

590578
let mut source_mut = world.entity_mut(self.source);
591-
dbg!(self.source);
592579
source_mut
593580
.insert((
594581
OperationExecuteStorage(perform_operation::<Op>),

src/operation/operate_task.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ impl<Response: 'static + Send + Sync> Operation for OperateTask<Response> {
225225
) {
226226
Poll::Ready(result) => {
227227
// Task has finished
228-
println!(" == READY: {source:?}");
229228
let r = world.entity_mut(target).give_input(session, result, roster);
230229
world.get_mut::<OperateTask<Response>>(source).or_broken()?.finished_normally = true;
231230
cleanup_task::<Response>(session, source, node, unblock, being_cleaned, world, roster);
@@ -272,19 +271,18 @@ impl<Response: 'static + Send + Sync> Operation for OperateTask<Response> {
272271
let task = operation.task.take();
273272
let unblock = operation.blocker.take();
274273
let sender = operation.sender.clone();
275-
dbg!(source, node);
276-
AsyncComputeTaskPool::get().spawn(async move {
277-
if let Some(task) = task {
278-
dbg!(source, node);
274+
if let Some(task) = task {
275+
AsyncComputeTaskPool::get().spawn(async move {
279276
task.cancel().await;
280-
dbg!(source, node);
281-
}
282-
if let Err(err) = sender.send(Box::new(move |world: &mut World, roster: &mut OperationRoster| {
283-
cleanup_task::<Response>(session, source, node, unblock, true, world, roster);
284-
})) {
285-
eprintln!("Failed to send a command to cleanup a task: {err}");
286-
}
287-
}).detach();
277+
if let Err(err) = sender.send(Box::new(move |world: &mut World, roster: &mut OperationRoster| {
278+
cleanup_task::<Response>(session, source, node, unblock, true, world, roster);
279+
})) {
280+
eprintln!("Failed to send a command to cleanup a task: {err}");
281+
}
282+
}).detach();
283+
} else {
284+
cleanup_task::<Response>(session, source, node, unblock, true, clean.world, clean.roster);
285+
}
288286

289287
Ok(())
290288
}
@@ -329,7 +327,6 @@ fn cleanup_task<Response>(
329327
if being_cleaned && cleanup_ready {
330328
// We are notifying about the cleanup on behalf of the node that
331329
// created this task, so we set initialize as source: node
332-
dbg!(source, node);
333330
let mut cleanup = OperationCleanup {
334331
source: node, session, world, roster
335332
};
@@ -378,26 +375,23 @@ pub struct ActiveTask {
378375
impl ActiveTasksStorage {
379376
pub fn cleanup(mut cleaner: OperationCleanup) -> OperationResult {
380377
let source = cleaner.source;
381-
let source_ref = cleaner.world.get_entity(cleaner.source).or_broken()?;
378+
let source_ref = cleaner.world.get_entity(source).or_broken()?;
382379
let active_tasks = source_ref.get::<Self>().or_broken()?;
383380
let mut to_cleanup: SmallVec<[Entity; 16]> = SmallVec::new();
384381
let mut cleanup_ready = true;
385382
for ActiveTask { task_id: id, session } in &active_tasks.list {
386383
if *session == cleaner.session {
387-
dbg!(source, *id, *session);
388384
to_cleanup.push(*id);
389385
cleanup_ready = false;
390386
}
391387
}
392388

393389
for task_id in to_cleanup {
394-
dbg!(source, task_id);
395390
cleaner = cleaner.for_node(task_id);
396391
cleaner.clean();
397392
}
398393

399394
if cleanup_ready {
400-
dbg!(source);
401395
cleaner.notify_cleaned()?;
402396
}
403397

src/operation/scope.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ where
426426
continue;
427427
};
428428

429-
dbg!(&cancellation);
430429
if pair.status.to_cancelled(cancellation.clone()) {
431430
cleanup_entire_scope(OperationCleanup {
432431
source, session: scoped_session, world, roster,
@@ -469,7 +468,6 @@ where
469468
.find(|pair| pair.scoped_session == scoped_session)
470469
.or_not_ready()?;
471470

472-
dbg!(&disposals);
473471
if pair.status.to_cancelled(Unreachability {
474472
scope: clean.source,
475473
session: pair.parent_session,
@@ -482,7 +480,6 @@ where
482480
}
483481

484482
fn finalize_scope_cleanup(clean: OperationCleanup) -> OperationResult {
485-
dbg!();
486483
let source = clean.source;
487484
let mut source_mut = clean.world.get_entity_mut(clean.source).or_broken()?;
488485
let mut pairs = source_mut.get_mut::<ScopedSessionStorage>().or_broken()?;
@@ -507,7 +504,6 @@ where
507504
None.or_broken()?;
508505
}
509506
ScopedSessionStatus::Finished => {
510-
dbg!();
511507
let (target, blocker) = source_mut.get_mut::<ExitTargetStorage>()
512508
.and_then(|mut storage| storage.map.remove(&scoped_session))
513509
.map(|exit| (exit.target, exit.blocker))
@@ -522,7 +518,7 @@ where
522518
.get_mut::<Staging<Response>>(terminal).or_broken()?.0
523519
.remove(&clean.session).or_broken()?;
524520

525-
clean.world.get_entity_mut(dbg!(target)).or_broken()?.give_input(
521+
clean.world.get_entity_mut(target).or_broken()?.give_input(
526522
pair.parent_session, response, clean.roster,
527523
)?;
528524

@@ -534,7 +530,6 @@ where
534530
clean.world.despawn(clean.session);
535531
}
536532
ScopedSessionStatus::Cleanup => {
537-
dbg!();
538533
let mut clean = clean.for_node(terminal);
539534
clean.cleanup_inputs::<Response>()?;
540535
let mut staging = clean.world.get_mut::<Staging<Response>>(clean.source).or_broken()?;
@@ -547,7 +542,6 @@ where
547542
)?;
548543
}
549544
ScopedSessionStatus::Cancelled(cancellation) => {
550-
dbg!();
551545
let mut clean = clean.for_node(terminal);
552546
clean.cleanup_inputs::<Response>()?;
553547
let mut staging = clean.world.get_mut::<Staging<Response>>(clean.source).or_broken()?;
@@ -753,7 +747,6 @@ impl ScopeContents {
753747
cleanup.insert(index, node);
754748
}
755749

756-
dbg!(&self.nodes, &cleanup);
757750
self.nodes == *cleanup
758751
}
759752

src/testing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ pub async fn wait<Value>(request: WaitRequest<Value>) -> Value {
267267
while elapsed < request.duration {
268268
let never = future::pending::<()>();
269269
let timeout = request.duration - elapsed;
270-
dbg!(request.duration, elapsed, timeout);
271270
let _ = future::timeout(timeout, never).await;
272271
elapsed = start.elapsed();
273272
}

src/workflow.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,21 +336,18 @@ mod tests {
336336
assert!(promise.peek().available().is_some_and(|v| *v == 3.0));
337337
assert!(context.no_unhandled_errors());
338338

339-
let start = std::time::Instant::now();
340339
let workflow = context.build_io_workflow(|scope, builder| {
341340
scope.input.chain(builder)
342341
.fork_clone_zip((
343342
|chain: Chain<f64>| chain
344343
.map_block(|t| WaitRequest { duration: Duration::from_secs_f64(10.0*t), value: 10.0*t })
345344
.map(|r: AsyncMap<WaitRequest<f64>>| {
346-
dbg!(r.source, r.request.value);
347345
wait(r.request)
348346
})
349347
.connect(scope.terminate),
350348
|chain: Chain<f64>| chain
351349
.map_block(|t| WaitRequest { duration: Duration::from_secs_f64(t/100.0), value: t/100.0 })
352350
.map(|r: AsyncMap<WaitRequest<f64>>| {
353-
dbg!(r.source, r.request.value);
354351
wait(r.request)
355352
})
356353
.connect(scope.terminate),
@@ -364,9 +361,6 @@ mod tests {
364361
});
365362

366363
context.run_with_conditions(&mut promise, Duration::from_secs_f64(0.5));
367-
dbg!(context.get_unhandled_errors());
368-
dbg!(promise.peek());
369-
println!("Elapsed time: {}", start.elapsed().as_secs_f64());
370364
assert!(promise.peek().available().is_some_and(|v| *v == 0.01));
371365
assert!(context.no_unhandled_errors());
372366
}

0 commit comments

Comments
 (0)