Skip to content

Instantly share code, notes, and snippets.

@manaten
Created January 5, 2015 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manaten/a1d2467ec571f5cac730 to your computer and use it in GitHub Desktop.
Save manaten/a1d2467ec571f5cac730 to your computer and use it in GitHub Desktop.
me = new MutualExclusion;
var hogeProcess = function(args, done) {
me.do(function(done) {
someAsync(function(err, result) {
done(err, result);
});
}, done);
}
hogeProcess(args1, function() {...});
hogeProcess(args2, function() {...}); //二回目のhogeProcessは一回目が完了してから実行される
// 実際はこう使いたい。
// botは不定期なタイミングでメッセージを受け取りうる。
// が、someAsyncがdoneせずに別のsomeAsyncが開始するのはまずい。
robot.hear(/hoge/, function (msg) {
hogeProcess(msg, function(err, result) {
msg.send(result);
});
};
@manaten
Copy link
Author

manaten commented Jan 5, 2015

someAsync は実際はシリアルポートへの複数回の通信を想定

@manaten
Copy link
Author

manaten commented Jan 5, 2015

botにメッセージ連続で投げられた時に、通信列Aに通信列Bが割り込んできたらまずいということです

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment