... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
| // Channels-driven concurrency with Go | |
| // Code examples from Rob Pike's talk on Google I/O 2012: | |
| // http://www.youtube.com/watch?v=f6kdp27TYZs&feature=youtu.be | |
| // | |
| // Concurrency is the key to designing high performance network services. | |
| // Go's concurrency primitives (goroutines and channels) provide a simple and efficient means | |
| // of expressing concurrent execution. In this talk we see how tricky concurrency | |
| // problems can be solved gracefully with simple Go code. | |
| // (1) Generator: function that returns the channel |
... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
| var express = require('express'); | |
| var cookieParser = require('cookie-parser'); | |
| var session = require('express-session'); | |
| var flash = require('express-flash'); | |
| var handlebars = require('express-handlebars') | |
| var app = express(); | |
| var sessionStore = new session.MemoryStore; | |
| // View Engines |
we're discussing how we can safely abort on unhandled rejections and obtain meaningful debugging information. Related reading: https://gist.github.com/misterdjules/2969aa1b5e6440a7e401#file-post-mortem-debugging-with-promises-md.
In particular, we're discussing https://gist.github.com/misterdjules/2969aa1b5e6440a7e401#removing-implicit-trycatch-blocks-from-v8s-promises-implementation
Othe recommended reading: On unhandledRejection https://gist.github.com/benjamingr/0237932cee84712951a2
using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies
| var os = require("os"); | |
| //Create function to get CPU information | |
| function cpuAverage() { | |
| //Initialise sum of idle and time of cores and fetch CPU info | |
| var totalIdle = 0, totalTick = 0; | |
| var cpus = os.cpus(); | |
| //Loop through CPU cores |