mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 17:00:04 +02:00
big leaps in git engine
This commit is contained in:
parent
21d204df92
commit
2cd620de27
4 changed files with 209 additions and 83 deletions
64
src/async.js
64
src/async.js
|
@ -2,9 +2,69 @@
|
|||
* Util classes
|
||||
*/
|
||||
|
||||
function CommandQueue() {
|
||||
this.commands = [];
|
||||
this.consumeTimeout = null;
|
||||
|
||||
/*
|
||||
var e = sys.addEdge(node1, node2);
|
||||
this.initialDelay = 400;
|
||||
}
|
||||
|
||||
CommandQueue.prototype.add = function(command) {
|
||||
this.commands.push(command);
|
||||
this.touchTimer();
|
||||
};
|
||||
|
||||
CommandQueue.prototype.touchTimer = function() {
|
||||
if (this.consumeTimeout) {
|
||||
return;
|
||||
}
|
||||
this.consumeTimeout = setTimeout(_.bind(function() {
|
||||
this.next();
|
||||
}, this), this.initialDelay);
|
||||
};
|
||||
|
||||
CommandQueue.prototype.reset = function() {
|
||||
this.consumeTimeout = null;
|
||||
};
|
||||
|
||||
CommandQueue.prototype.next = function() {
|
||||
if (this.commands.length == 0) {
|
||||
this.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
// execute the top command by passing it into the engine
|
||||
var toExecute = this.commands.shift(0);
|
||||
var callback = _.bind(function() {
|
||||
this.next();
|
||||
}, this);
|
||||
gitEngine.execute(toExecute, callback);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/******************
|
||||
* Planning:
|
||||
|
||||
here is the major flow:
|
||||
|
||||
someone types in a command ->
|
||||
make a new command object. if error, give immediate feedback, dont append to queue
|
||||
if not error ->
|
||||
append command object to queue
|
||||
|
||||
|
||||
Command Queue ->
|
||||
consume commands at a certain rate (either instantly if just added, or with an interval
|
||||
Execute command -> (usually a git engine thing)
|
||||
Wait for git engine command to finish
|
||||
when done, execute next command (if more)
|
||||
|
||||
so two levels of Async-ness:
|
||||
command queue slowly consumes commands
|
||||
|
||||
GitEngine executes commands, which will have async bits to them (such as popping off commits for a
|
||||
rebase)
|
||||
*/
|
||||
|
||||
function Scheduler(closures, options) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue