Created
January 5, 2015 11:16
-
-
Save manaten/a1d2467ec571f5cac730 to your computer and use it in GitHub Desktop.
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
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); | |
}); | |
}; |
botにメッセージ連続で投げられた時に、通信列Aに通信列Bが割り込んできたらまずいということです
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
someAsync は実際はシリアルポートへの複数回の通信を想定