Permalink
Browse files

2nd commit, D day

  • Loading branch information...
1 parent 5699739 commit ab01f72463849f01d16c68c2f11a26d447f55fc3 @xk xk committed Nov 22, 2011
Showing with 5,712 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +3 −0 .npmignore
  3. +5 −0 AUTHORS
  4. +11 −0 LICENSE
  5. 0 README
  6. +379 −0 README.md
  7. +27 −0 benchmark/b00_fibonacci_server_no_threads.js
  8. +42 −0 benchmark/b01_fibonacci_server_threads.js
  9. +36 −0 benchmark/b02_fibonacci_server_threads_pool.js
  10. +39 −0 benchmark/b03_fibonacci_server_clustered.js
  11. +14 −0 benchmark/b04_only_quick.js
  12. +637 −0 benchmark/doubles.c
  13. +153 −0 benchmark/pi.c
  14. +50 −0 benchmark/pi.js
  15. +39 −0 benchmark/pi.rb
  16. +50 −0 benchmark/pi_precompiled.js
  17. BIN deps/minifier/bin/minify
  18. +420 −0 deps/minifier/src/minify.c
  19. BIN deps/minifier/src/test
  20. +14 −0 deps/minifier/src/test.include.c
  21. +8 −0 deps/minifier/src/test_minifier.c
  22. +31 −0 examples/demo.js
  23. +63 −0 examples/ex01_basic.js
  24. +94 −0 examples/ex01_basic.md
  25. +54 −0 examples/ex02_events.js
  26. +73 −0 examples/ex02_events.md
  27. +57 −0 examples/ex03_ping_pong.js
  28. +80 −0 examples/ex03_ping_pong.md
  29. +40 −0 examples/ex04_main.js
  30. +51 −0 examples/ex04_main.md
  31. +15 −0 examples/ex04_worker.js
  32. +18 −0 examples/ex04_worker.md
  33. +52 −0 examples/ex05_pool.js
  34. +63 −0 examples/ex05_pool.md
  35. +39 −0 examples/ex06_complex.js
  36. +42 −0 examples/ex06_jason.js
  37. +61 −0 examples/ex06_jason.md
  38. +13 −0 examples/quickIntro_blocking.js
  39. +7 −0 examples/quickIntro_evented_childThreadCode.js
  40. +21 −0 examples/quickIntro_fiveThreads.js
  41. +4 −0 examples/quickIntro_loop.js
  42. +16 −0 examples/quickIntro_multiThread.js
  43. +30 −0 examples/quickIntro_multiThreadEvented.js
  44. +17 −0 examples/quickIntro_oneThread.js
  45. +29 −0 examples/quickIntro_oneThreadEvented.js
  46. +5 −0 node_modules/JASON/AUTHORS
  47. +287 −0 node_modules/JASON/index.js
  48. +7 −0 node_modules/JASON/package.json
  49. +44 −0 node_modules/JASON/readme.md
  50. +245 −0 node_modules/JASON/test/test01.js
  51. +36 −0 package.json
  52. +185 −0 src/createPool.js
  53. +1 −0 src/createPool.js.c
  54. +50 −0 src/events.js
  55. +1 −0 src/events.js.c
  56. +3 −0 src/load.js
  57. +1 −0 src/load.js.c
  58. +159 −0 src/queues_a_gogo.cc
  59. +34 −0 src/thread_nextTick.js
  60. +1 −0 src/thread_nextTick.js.c
  61. +745 −0 src/threads_a_gogo.cc
  62. +96 −0 test/ab.js
  63. +27 −0 test/test00_run_once_and_destroy.js
  64. +84 −0 test/test01_loop_as_fast_as_possible.js
  65. +32 −0 test/test02_loop_as_fast_as_possible.js
  66. +32 −0 test/test03_infiniteLoopFunction.js
  67. +44 −0 test/test04_gc_versus_not_gc.js
  68. +32 −0 test/test05_debugLeaksNoCallbacks.js
  69. +12 −0 test/test06_throw_from_the_thread.js
  70. +24 −0 test/test07_sigkill.js
  71. +30 −0 test/test08_sigkill_leaks.js
  72. +15 −0 test/test09_throw_from_the_callback.js
  73. +35 −0 test/test10_node_nextTick_speed.js
  74. +38 −0 test/test11_multi_callbacks.js
  75. +42 −0 test/test12_precompiled_vs_normal.js
  76. +31 −0 test/test13_thread_nextTick_speed.js
  77. +20 −0 test/test14_emit_once.js
  78. +31 −0 test/test15_emit_ping_pong.js
  79. +13 −0 test/test16_syntax_error_in_the_thread.js
  80. +67 −0 test/test17_pool_pi.js
  81. +47 −0 test/test18_pool_any_as_fast_as_possible.js
  82. +37 −0 test/test19_pool_emit_any_all.js
  83. +23 −0 test/test20_removeAllListeners.js
  84. +32 −0 test/test21_emit_ping_pong_big_string.js
  85. +25 −0 test/test22_create_destroy_loop.js
  86. +25 −0 test/test23_create_destroy_loop.js
  87. +17 −0 test/test24_puts.js
  88. +23 −0 test/test25_delete_puts.js
  89. +18 −0 test/test26_puts_with_many_args.js
  90. +56 −0 wscript
View
@@ -0,0 +1,3 @@
+build
+.lock-wscript
+.DS_Store
View
@@ -0,0 +1,3 @@
+threads_a_gogo.node
+build
+.lock-wscript
View
@@ -0,0 +1,5 @@
+//Threads_a_gogo AUTHORS
+
+2011-11-06 Jorge Chamorro Bieling <jorge@jorgechamorro.com>
+2011-11-25 Juan Falgueras Cano <juan.falgueras@gmail.com>
+2012-01-26 Bruno Jouhier <bjouhier@gmail.com>
View
@@ -0,0 +1,11 @@
+Threads_a_gogo license follows:
+
+====
+
+Copyright 2011 Proyectos Equis Ka, s.l., Jorge Chamorro Bieling and other
+contributors. See the AUTHORS file. All rights reserved.
+
+====
+
+This license applies to all parts of Threads_a_gogo that are not externally
+maintained libraries.
View
No changes.
View
Oops, something went wrong.
@@ -0,0 +1,27 @@
+
+
+function fib (n) {
+ return (n < 2) ? 1 : fib(n-2)+ fib(n-1);
+}
+
+var i= 0;
+var n= 35;
+function ƒ (req, res) {
+ if ((++i) % 10) {
+ res.end(" QUICK");
+ process.stdout.write(" QUICK");
+ }
+ else {
+ var txt= ' '+ fib(n);
+ res.end(txt);
+ process.stdout.write(txt);
+ }
+}
+
+
+var port= +process.argv[2] || 1234;
+var http= require('http');
+http.globalAgent.maxSockets= 8192+2048;
+http.createServer(ƒ).listen(port);
+console.log('Fibonacci server (NO THREADS) running @port: '+ port);
+
@@ -0,0 +1,42 @@
+
+
+function fib (n) {
+ return (n < 2) ? 1 : fib(n-2)+ fib(n-1);
+}
+
+//We're going to use n threads
+var numThreads= +process.argv[3] || 1;
+console.log("Using "+ numThreads+ " threads");
+
+var threads= [];
+var round_robin= 0;
+var t= require('threads_a_gogo');
+while (numThreads--) {
+ threads.push(t.create().eval(fib));
+}
+
+var i= 0;
+var n= 35;
+function ƒ (req, res) {
+ if ((++i) % 10) {
+ res.end(" QUICK");
+ process.stdout.write(" QUICK");
+ }
+ else {
+ round_robin= (++round_robin) % threads.length;
+ threads[round_robin].eval('fib('+ n+ ')', function cb (err, data) {
+ if (err) throw err;
+ var txt= ' '+ data;
+ res.end(txt);
+ process.stdout.write(txt);
+ });
+ }
+}
+
+
+var port= +process.argv[2] || 1234;
+var http= require('http');
+http.globalAgent.maxSockets= 8192+2048;
+http.createServer(ƒ).listen(port);
+console.log('Fibonacci server (WITH THREADS) running @port: '+ port);
+
@@ -0,0 +1,36 @@
+
+
+function fib (n) {
+ return (n < 2) ? 1 : fib(n-2)+ fib(n-1);
+}
+
+//We're going to use n threads
+var numThreads= +process.argv[3] || 1;
+console.log("Using a POOL of "+ numThreads+ " threads");
+
+var pool= require('threads_a_gogo').createPool(numThreads).all.eval(fib);
+
+var i= 0;
+var n= 35;
+function ƒ (req, res) {
+ if ((++i) % 10) {
+ res.end(" QUICK");
+ process.stdout.write(" QUICK");
+ }
+ else {
+ pool.any.eval('fib('+ n+ ')', function cb (err, data) {
+ if (err) throw err;
+ var txt= ' '+ data;
+ res.end(txt);
+ process.stdout.write(txt);
+ });
+ }
+}
+
+
+var port= +process.argv[2] || 1234;
+var http= require('http');
+http.globalAgent.maxSockets= 8192+2048;
+http.createServer(ƒ).listen(port);
+console.log('Fibonacci server (WITH A THREAD POOL) running @port: '+ port);
+
@@ -0,0 +1,39 @@
+
+
+function fib (n) {
+ return (n < 2) ? 1 : fib(n-2)+ fib(n-1);
+}
+
+var i= 0;
+var n= 35;
+function ƒ (req, res) {
+ if ((++i) % 10) {
+ res.end(" QUICK");
+ process.stdout.write(" QUICK");
+ }
+ else {
+ var txt= ' '+ fib(n);
+ res.end(txt);
+ process.stdout.write(txt);
+ }
+}
+
+var cluster = require('cluster');
+if (cluster.isMaster) {
+ require('http').globalAgent.maxSockets= 8192+2048;
+ var numCPUs = process.argv[3] || 1;
+ for (var i = 0; i < numCPUs; i++) {
+ cluster.fork();
+ }
+
+ cluster.on('death', function(worker) {
+ console.log('worker ' + worker.pid + ' died');
+ });
+} else {
+ var port= + process.argv[2] || 1234;
+ var http= require('http');
+ http.globalAgent.maxSockets= 8192+2048;
+ http.createServer(ƒ).listen(port);
+ console.log('Fibonacci server (CLUSTERED) listening: ' + port);
+}
+
@@ -0,0 +1,14 @@
+
+
+function ƒ (req, res) {
+ res.end(" QUICK");
+ process.stdout.write(" QUICK");
+}
+
+
+var port= +process.argv[2] || 1234;
+var http= require('http');
+http.globalAgent.maxSockets= 8192+2048;
+http.createServer(ƒ).listen(port);
+console.log('Fibonacci server (NO THREADS) running @port: '+ port);
+
Oops, something went wrong.

0 comments on commit ab01f72

Please sign in to comment.