Browse Source

Define a constant for the channel buffer size.

wip
Titouan Rigoudy 4 years ago
parent
commit
fd8bed689d
1 changed files with 9 additions and 6 deletions
  1. +9
    -6
      client/src/main.rs

+ 9
- 6
client/src/main.rs View File

@ -25,9 +25,14 @@ use config::{Config, TomlConfig};
use context::{ContextBundle, ContextOptions};
use dispatcher::Dispatcher;
// Size of various channels defined below.
const CHANNEL_BUFFER_SIZE: usize = 100;
fn old_main(config: Config) {
let (request_tx, _request_rx) = crossbeam_channel::bounded(100);
let (_response_tx, response_rx) = crossbeam_channel::bounded(100);
let (request_tx, _request_rx) =
crossbeam_channel::bounded(CHANNEL_BUFFER_SIZE);
let (_response_tx, response_rx) =
crossbeam_channel::bounded(CHANNEL_BUFFER_SIZE);
let mut client = client::Client::new(request_tx, response_rx, config);
@ -52,8 +57,7 @@ async fn run_client(
.context("logging in")?;
info!("Login successful.");
// TODO: Define a constant for this, or something.
let (response_tx, mut response_rx) = mpsc::channel(100);
let (response_tx, mut response_rx) = mpsc::channel(CHANNEL_BUFFER_SIZE);
let forwarder_task = tokio::spawn(async move {
while let Some(response) = response_rx.recv().await {
dispatcher_tx
@ -83,8 +87,7 @@ async fn async_main(config: Config) -> anyhow::Result<()> {
let bundle = ContextBundle::new(options);
// TODO: Define a constant for this, or something.
let (dispatcher_tx, mut dispatcher_rx) = mpsc::channel(100);
let (dispatcher_tx, mut dispatcher_rx) = mpsc::channel(CHANNEL_BUFFER_SIZE);
let mut control_listener =
control::Listener::bind(&config.control_listen_address)


Loading…
Cancel
Save