/
LavrGov
/
thread_pool
Обзор
Документация
Войти
/
LavrGov
/
thread_pool
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
rust_pool/src/main.rs
34 строки
600 B
Lavrentiy
Realizing your own simple thread pool in c++ and rust
08 май 2025, 22:19
08 май 2025, 22:19
0fc8cf1
Код
Авторство
О чём код?
mod thread_pool; mod queue; use std::{ops::Add, sync::Mutex, thread::Thread}; use thread_pool::ThreadPool; static mut data: i32 = 0; static mut data1: Mutex<i32> = Mutex::new(0); fn test() { unsafe { data += 1; } } fn test1() { unsafe { let guard = data1.lock().unwrap(); guard.add(1); } } fn main() { let mut new_pool = ThreadPool::new(4); for _ in 0..1000000 { new_pool.spawn(test); } std::thread::sleep(std::time::Duration::from_millis(10000)); unsafe { println!("{}", data); } println!("Hello, world!"); }