This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -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();

View file

@ -0,0 +1,2 @@
(doseq [text ["Enjoy" "Rosetta" "Code"]]
(future (println text)))

View file

@ -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)))

View file

@ -0,0 +1,5 @@
{ exec } = require 'child_process'
for word in [ 'Enjoy', 'Rosetta', 'Code' ]
exec "echo #{word}", (err, stdout) ->
console.log stdout

View file

@ -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

View file

@ -0,0 +1,3 @@
# child.coffee
console.log process.argv[ 2 ]

View file

@ -0,0 +1,3 @@
inline(func);
func(n)=print(["Enjoy","Rosetta","Code"][n]);
parapply(func,[1..3]);

View file

@ -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");
}
}