mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Start re-transformation as soon as possible in TokenAccumulator._returnTokens
to maximize IO concurrency. Signal that all tokens are fully transformed to callbacks called from TokenAccumulator._returnTokens. The result should be a single re-transformation when entering the callback chain, and only if the transform does not signal that it took care of full transformation itself. Template expansion would set this flag, as the nested transform pipeline processes all tokens to the end of phase async12.
This commit is contained in:
parent
656524dbbc
commit
e5a1116817
Notes:
Gabriel Wicke
2012-03-07 16:29:06 +00:00
|
@ -458,11 +458,6 @@ AsyncTokenTransformManager.prototype.onChunk = function ( tokens ) {
|
|||
this.tailAccumulator = res.async;
|
||||
this.tokenCB = res.async.getParentCB ( 'sibling' );
|
||||
}
|
||||
|
||||
// The next processed chunk should call back as a sibling to last
|
||||
// accumulator, if any.
|
||||
//if ( res.async ) {
|
||||
//}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -952,21 +947,36 @@ TokenAccumulator.prototype.getParentCB = function ( reference ) {
|
|||
*/
|
||||
TokenAccumulator.prototype._returnTokens =
|
||||
function ( reference, tokens, notYetDone, allTokensProcessed ) {
|
||||
var res,
|
||||
cb,
|
||||
var cb,
|
||||
returnTokens = [];
|
||||
|
||||
|
||||
if ( ! notYetDone ) {
|
||||
this.outstanding--;
|
||||
}
|
||||
|
||||
//console.warn( 'TokenAccumulator._returnTokens' );
|
||||
if ( reference === 'child' ) {
|
||||
var res = {};
|
||||
if( !allTokensProcessed ) {
|
||||
// There might be transformations missing on the returned tokens,
|
||||
// re-transform to make sure those are applied too.
|
||||
res = this.manager.transformTokens( tokens, this.parentCB );
|
||||
tokens = res.tokens;
|
||||
}
|
||||
|
||||
if ( !notYetDone ) {
|
||||
// empty accum too
|
||||
tokens = tokens.concat( this.accum );
|
||||
this.accum = [];
|
||||
}
|
||||
this.manager.env.dp( 'TokenAccumulator._returnTokens child: ',
|
||||
tokens, ' outstanding: ', this.outstanding );
|
||||
this.accum = [];
|
||||
this.parentCB( tokens, this.outstanding );
|
||||
this.parentCB( tokens, this.outstanding, true );
|
||||
|
||||
if ( res.async ) {
|
||||
this.parentCB = res.async.getParentCB( 'sibling' );
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
// sibling
|
||||
|
@ -977,7 +987,7 @@ TokenAccumulator.prototype._returnTokens =
|
|||
this.manager.env.dp( 'TokenAccumulator._returnTokens: ',
|
||||
'sibling done and parentCB ',
|
||||
tokens );
|
||||
this.parentCB( tokens, false );
|
||||
this.parentCB( tokens, false, true );
|
||||
return null;
|
||||
} else if ( this.outstanding === 1 && notYetDone ) {
|
||||
this.manager.env.dp( 'TokenAccumulator._returnTokens: ',
|
||||
|
@ -987,7 +997,7 @@ TokenAccumulator.prototype._returnTokens =
|
|||
// allow the sibling to go direct, and call back parent with
|
||||
// tokens. The internal accumulator is empty at this stage, as its
|
||||
// tokens are passed to the parent when the child is done.
|
||||
return this.parentCB( tokens, true);
|
||||
return this.parentCB( tokens, true, true);
|
||||
} else {
|
||||
this.accum = this.accum.concat( tokens );
|
||||
this.manager.env.dp( 'TokenAccumulator._returnTokens: sibling done, but not overall. notYetDone=',
|
||||
|
|
Loading…
Reference in a new issue