当前位置:网站首页>D parallel and rotator
D parallel and rotator
2022-06-29 04:50:00 【fqbqrr】
import std.stdio;
import std.concurrency;
import core.thread;
void main() {
spawnLinked(&spinner, 100.msecs);
enum n = 45;
const fibN = fib(n); // slow
writefln!"\rFibonacci(%d) = %d"(n, fibN);
}
void spinner(const(Duration) delay) {
for (;;) {
foreach (r; `-\|/`) {
writef!"\r%c"(r);
stdout.flush();
bool done;
receiveTimeout(delay,
(OwnerTerminated msg) {
done = true;
});
if (done) {
return;
}
}
}
}
auto fib(int x) {
if (x < 2) {
return x;
}
return fib(x-1) + fib(x-2);
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
D parallel Fib. Check the return value :
if (receiveTimeout(delay, (OwnerTerminated msg) {})) {
return;
}
- 1.
- 2.
- 3.
边栏推荐
- Cisco voice card handling configuration
- JDBC learning
- docker 创建的 mysql8 怎么改密码
- MySQL subquery
- Test content
- How to create robots Txt file?
- 5000+ word interpretation | Product Manager: how to do a good job in component selection?
- 【代码随想录-哈希表】T15、三数之和-双指针+排序
- 波形记录仪MR6000的实时波形运算功能
- Research Report on the overall scale, major manufacturers, major regions, products and applications of high temperature film capacitors in the global market in 2022
猜你喜欢

Technical parameters of Tektronix DPO4104 digital fluorescence oscilloscope

基于.NetCore开发博客项目 StarBlog - (13) 加入友情链接功能

Technical specifications of Tektronix tds3054b oscilloscope

Annual inventory review of Alibaba cloud's observable practices in 2021

The 30th day of force deduction (DP topic)
![[high concurrency] deeply analyze the callable interface](/img/42/43d1f0b894f2632f2c7f1bfe970708.jpg)
[high concurrency] deeply analyze the callable interface

What is the method of connection query in MySQL

Command pattern

How to create robots Txt file?

Cloud native annual technology inventory is released! Ride the wind and waves at the right time
随机推荐
Research Report on the overall scale, major manufacturers, major regions, products and application segments of 5g modules of the Internet of things in the global market in 2022
[performance test] introduction and installation of JMeter
What are the basic usage methods of MySQL
What is an anonymous inner class and how to use it
GBASE 8s must be a DBSA、路径更改导致无法启动的解决方法
Annual inventory review of Alibaba cloud's observable practices in 2021
An efficient flutter hybrid stack management scheme with zero intrusion, you deserve it!
Structure training camp module II operation
Mediator pattern
On February 15, the market hot money operation and the dragon and tiger list
Cloud native annual technology inventory is released! Ride the wind and waves at the right time
机器人强化学习——第一人称 VS 第三人称
[high concurrency] deeply analyze the callable interface
Is the interviewer too difficult to serve? A try catch asks so many tricks
Use typescript compiler parameter 'skiplibcheck' - usage of the typescript compiler argument'skiplibcheck'
How to create a subtype like relationship between two generic classes when the classes are generic related
Iterator pattern
MySQL subquery
Experience sharing of system analysts in preparing for exams: phased and focused
i-Teams W3: How to build a sound-bottling business