diff --git a/src/container_pool.rs b/src/container_pool.rs index 6868c80..37145d2 100644 --- a/src/container_pool.rs +++ b/src/container_pool.rs @@ -24,6 +24,7 @@ impl ContainerPool { false } }) { + println!("Using container from pool"); let container = pool[i].clone(); pool.remove(i); container @@ -31,4 +32,11 @@ impl ContainerPool { Container::from_language(language).await } } + + pub async fn add_container(&mut self, language: Language) { + self.containers + .lock() + .await + .push(Container::from_language(language).await); + } } diff --git a/src/main.rs b/src/main.rs index ff65bb3..bf92ad9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,6 +50,12 @@ async fn main() -> Result<(), ()> { let intents = serenity::GatewayIntents::non_privileged() | serenity::GatewayIntents::MESSAGE_CONTENT; + let mut pool = ContainerPool::new(); + for _ in 0..10 { + pool.add_container(config.get_language(&"Ruby".to_string()).unwrap()) + .await; + } + let framework = poise::Framework::builder() .setup({ let config = config.clone(); @@ -57,7 +63,7 @@ async fn main() -> Result<(), ()> { Box::pin(async move { Ok(Data { config: Arc::new(Mutex::new(config)), - container_pool: Arc::new(Mutex::new(ContainerPool::new())), + container_pool: Arc::new(Mutex::new(pool)), }) }) }