Skip to content

Commit

Permalink
book: Use bounded channels instead of unbounded (#1522)
Browse files Browse the repository at this point in the history
They should be enough in most situations.
  • Loading branch information
Hofer-Julian authored Oct 22, 2023
1 parent 3641400 commit fb3ef4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion book/listings/main_event_loop/3/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ fn build_ui(app: &Application) {
.build();

// ANCHOR: callback
let (sender, receiver) = async_channel::unbounded();
// Create channel that can hold at most 1 message at a time
let (sender, receiver) = async_channel::bounded(1);
// Connect to "clicked" signal of `button`
button.connect_clicked(move |_| {
let sender = sender.clone();
Expand Down
3 changes: 2 additions & 1 deletion book/listings/main_event_loop/4/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ fn build_ui(app: &Application) {
.build();

// ANCHOR: callback
let (sender, receiver) = async_channel::unbounded();
// Create channel that can hold at most 1 message at a time
let (sender, receiver) = async_channel::bounded(1);
// Connect to "clicked" signal of `button`
button.connect_clicked(move |_| {
let main_context = MainContext::default();
Expand Down

0 comments on commit fb3ef4d

Please sign in to comment.