9. So instead of this: http/ https Persistent connections Browser Browser Browser Web Server (Apache/ IIS) CSP Caché CSP interface Caché CSP interface Your scripts Your data EWD CSP pages
10. You'd have something like this: Browser Browser Browser Cach é http/ https WebLink interface Cach é CSP interface Child_process connections EWD Runtime Your scripts Your data EWD routines Node.js process Javascript Web server & request/response Handling logic stdin/stdout GT.M or Cach é
18. Asynchronous I/O & Javascript Synchronous read from a file in MUMPS: set file = "mydata.txt" open file:"r" use file read buffer // do something with the buffer contents … . // then move on to the next task
19. Asynchronous I/O & Javascript Synchronous read from a file in MUMPS: set file = "mydata.txt" open file:"r" use file read buffer // do something with the buffer contents … .// at this point the thread is blocked … .// until the buffer contents are read from the file // then move on to the next task
20. Asynchronous I/O & Javascript The Asynchronous way in Javascript: var fs = require('fs'); fs.readFile('mydata.txt', function (err, buffer) { // Do something with the data in the buffer }); // Immediately execute the next statements // while it waits for I/O
30. Dependent callbacks myFunc1(inputs, function(error, results) { var value = results.value; // myFunc2 can't run until myFunc1 returns its results myFunc2(value, function(error, results) { var myResult = results.value; }); });
31. Concurrent callbacks var count = 0; myFunc1(inputs, function(error, results) { count++; if (count === 3) myFunc4(inputs); }); myFunc2(inputs, function(error, results) { count++; if (count === 3) myFunc4(inputs); }); myFunc3(inputs, function(error, results) { count++; if (count === 3) myFunc4(inputs); }); // myFunc isn't invoked until all 3 functions are complete // Uses the properties of closures to allow count to be incremented by // the callbacks in the three functions