Skip to content

Commit bbe8ed0

Browse files
Concurrent execution of event handlers in dispatcher
1 parent 7611215 commit bbe8ed0

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/event-bus/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ doctest = false
2020
[dependencies]
2121
internal-error = { workspace = true }
2222
dill = "0.7"
23+
futures = "0.3"
2324

2425
[dev-dependencies]

src/utils/event-bus/src/event_bus.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ impl EventBus {
4747
}
4848
};
4949

50-
// TODO: concurrent launch
51-
for handler in handlers.iter() {
52-
(*handler)
53-
.call((self.catalog.clone(), event.clone()))
54-
.await?;
55-
}
50+
let handler_futures: Vec<_> = handlers
51+
.iter()
52+
.map(|handler| (*handler).call((self.catalog.clone(), event.clone())))
53+
.collect();
54+
55+
futures::future::try_join_all(handler_futures).await?;
5656

5757
Ok(())
5858
}

0 commit comments

Comments
 (0)