当前位置:网站首页>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.
边栏推荐
- [high concurrency] deeply analyze the callable interface
- 机器人强化学习——第一人称 VS 第三人称
- What are the basic usage methods of MySQL
- Satellite navigation time service related terms Collection Edition
- Research Report on the overall scale, major manufacturers, major regions, products and applications of high temperature film capacitors in the global market in 2022
- [code random entry - hash table] T15, sum of three numbers - double pointer + sort
- Notebook access desktop shared disk
- Cipher
- Test content
- Résultats D - exam de Qinhuangdao au cours des 20 dernières années
猜你喜欢

JDBC learning

《软件体系结构》期末复习总结

What is the method of connection query in MySQL
![[structural mechanics] the reason why the influence line under joint load is different from that under direct load](/img/a6/fce0bb29cc5c84bc0ef20501617e06.png)
[structural mechanics] the reason why the influence line under joint load is different from that under direct load

Template method pattern

Iterator pattern

Service grid ASM year end summary: how do end users use the service grid?

See how I do it step by step (I)

机器人强化学习——Transferring End-to-End Visuomotor Control from Simulation to RealWorld (CoRL 2017)

Cloud native annual technology inventory is released! Ride the wind and waves at the right time
随机推荐
Robot reinforcement learning - transferring end-to-end videomotor control from simulation to realworld (curl 2017)
Research Report on the overall scale, major manufacturers, major regions, product and application segmentation of spinning flow forming hub in the global market in 2022
网传广东一名学生3次考上北大,3年共赚200万元奖金
软件体系结构实验汇总
Research Report on the overall scale, major manufacturers, major regions, products and applications of high temperature film capacitors in the global market in 2022
What if modstart forgets the background user or password?
【HackTheBox】dancing(SMB)
Hi, my technology forum is online!
From zero to one, I will teach you to build a "search by text and map" search service (I)
Le langage C imprime "Love", "Mars hit Earth" et ainsi de suite en utilisant printf, qui est constamment mis à jour
Untitled
The 30th day of force deduction (DP topic)
be based on. NETCORE development blog project starblog - (13) add friendship link function
What are the MySQL database constraint types
How to create robots Txt file?
【IoT】公众号“简一商业”更名为“产品人卫朋”说明
To learn more about Yibo Hongmeng development
嵌入式RTOS
EEG signal processing - wavelet transform series
JDBC man Han building code