大道至简,简即是繁
- 个人网站: https://colobu.com
- 最好的Go微服务框架: https://rpcx.io
- rpcx官方博客: https://blog.rpcx.io
License: Apache License 2.0
大道至简,简即是繁
error: the crate atomic_mpmc
could not be found in registry index
44页
ThreadPool::builder()
.core_threads(4)
.max_threads(8)
.keep_alive(Duration::from_secs(30))
.build();
=>
threadpool::Builder::new()
.core_pool_size(4)
.maximum_pool_size(8)
.keep_alive_time(Duration::from_secs(30))
.build();
pool.execute(async {
// ...
});
应该不支持
45页
let result = pool.execute(|| {
Ok(1 + 2)
})?;
let res = result.unwrap().get_result_timeout(std::time::Duration::from_secs(3))
;
assert!(res.is_err());
if let Err(err) = res {
matches!(err.kind(), threadpool_executor::error::ErrorKind::TimeOut);
}
=>
let mut result: threadpool_executor::Expectation<Result<i32, ()>> = pool
.execute(|| {
thread::sleep(Duration::from_secs(5));
Ok(1 + 2)
})
.unwrap();
let res = result.get_result_timeout(Duration::from_secs(3));
assert!(res.is_err());
if let Err(e) = res {
assert!(matches!(
e.kind(),
threadpool_executor::error::ErrorKind::TimeOut
));
}
第40页
可以通过 Builder 自定义线程数:
let pool = poolite::Pool::builder().thread_num(8).build()?;
貌似没有builder这个方法
是不是应该
poolite::Builder::new().max(8).build()?
note: Some details are omitted, run with RUST_BACKTRACE=full
for a verbose backtrace.
thread 'main' panicked at 'task panicked while holding lock: PoisonError { .. }'...
First of all, thank you very much for your impressive effort. Do you have any plans for releasing English version of this book ?
Thanks
special章节改成这样能编译成功
scc = "1.4.4"
Is there an online site where you can read it? Like the book "Rust High Performance Programming Guide"?tks!
42页
支持闭包、Future 等任务形式:
pool.spawn(async {});
spawn方法应该没有
43页
4. 提供方便的线程池构建器
ThreadPoolExecutor应该没有 像是把threadpool_executor库的写错到这里了
改成这样能编译成功
atomic_mpmc = {git="https://github.com/DexterHaxxor/atomic_mpmc",version="0.2.0"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.