This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
char **ptr; /* global */ | |
/* thread routine */ | |
void *thread(void *vargp) | |
{ | |
int64_t myid = (int64_t)vargp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <semaphore.h> | |
#include <stdio.h> | |
#include <errno.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <sys/mman.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <semaphore.h> | |
#include <stdio.h> | |
#include <errno.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <sys/mman.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require('q'); | |
(function(){ | |
Q.fcall(function(){ | |
return Q.all([ | |
(function(){ | |
var d = Q.defer(); | |
d.resolve('hi'); | |
console.log('test1'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require('q'); | |
Q.fcall([ | |
(function(){ | |
setTimeout(function(){ | |
console.log('func1'); | |
},5000) | |
})(), | |
(function(){ | |
setTimeout(function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function a(v1,v2, callback1) { | |
console.log(v1, v2); | |
callback1(7,8,function(){console.log('hi');}); | |
} | |
a(5, 6, a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = Q(); | |
func.push(function(){ | |
var d = Q.defer(); | |
d.resolve('a'); | |
return d.promise; | |
}); | |
func.push(function(){ | |
console.log(arguments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require('q'); | |
var func = []; | |
func.push(function (){ | |
var d = Q.defer(); | |
d.resolve('a'); | |
console.log('a'); | |
return d.promise; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require('q'); | |
var funcs = []; | |
for (var i = 0; i < 3; i++) { | |
funcs.push((function(m){ | |
return function() { | |
var d = Q.defer(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async'); | |
var products = ['a', 'b', 'c', 'd', 'e']; | |
var funcs = []; | |
products.forEach(function(item){ | |
funcs.push( | |
function(callback){ | |
async.waterfall([ |
OlderNewer