Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -11,14 +11,14 @@ int main()
|
|||
std::uniform_int_distribution<> dist(1,1000);
|
||||
std::vector<std::thread> threads;
|
||||
|
||||
for(auto& str: {"Enjoy\n", "Rosetta\n", "Code\n"}) {
|
||||
for(const auto& str: {"Enjoy\n", "Rosetta\n", "Code\n"}) {
|
||||
// between 1 and 1000ms per our distribution
|
||||
std::chrono::milliseconds duration(dist(eng));
|
||||
|
||||
threads.push_back(std::thread([str, duration](){
|
||||
threads.emplace_back([str, duration](){
|
||||
std::this_thread::sleep_for(duration);
|
||||
std::cout << str;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
for(auto& t: threads) t.join();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
(doseq [text ["Enjoy" "Rosetta" "Code"]]
|
||||
(future (println text)))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(require '[clojure.core.async :refer [go <! timeout]])
|
||||
(doseq [text ["Enjoy" "Rosetta" "Code"]]
|
||||
(go
|
||||
(<! (timeout (rand-int 1000))) ; wait a random fraction of a second,
|
||||
(println text)))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{ exec } = require 'child_process'
|
||||
|
||||
for word in [ 'Enjoy', 'Rosetta', 'Code' ]
|
||||
exec "echo #{word}", (err, stdout) ->
|
||||
console.log stdout
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# The "master" file.
|
||||
|
||||
{ fork } = require 'child_process'
|
||||
path = require 'path'
|
||||
child_name = path.join __dirname, 'child.coffee'
|
||||
words = [ 'Enjoy', 'Rosetta', 'Code' ]
|
||||
|
||||
fork child_name, [ word ] for word in words
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# child.coffee
|
||||
|
||||
console.log process.argv[ 2 ]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
inline(func);
|
||||
func(n)=print(["Enjoy","Rosetta","Code"][n]);
|
||||
parapply(func,[1..3]);
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
void
|
||||
foo()
|
||||
{
|
||||
if (pari_daemon()) {
|
||||
// Original
|
||||
if (pari_daemon()) {
|
||||
// Original
|
||||
pari_printf("Enjoy\n");
|
||||
} else {
|
||||
// Daemon #2
|
||||
pari_printf("Code\n");
|
||||
}
|
||||
} else {
|
||||
// Daemon #1
|
||||
pari_printf("Rosetta\n");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue