Hi!
I wrote the code below for a custom tag <xdata>. This tag can appear more than once in the same article.
Suppose the custom tag appears exactly 5 times in an article. It appears that the renderXdata() function below would be invoked 5 times too. My question is: Is this function called (executed) serially or in parallel?
If it's run serially, is there a way to run them in parallel?
function wfXdataExtension() { global $wgParser; $wgParser->setHook( "xdata", "renderXdata" ); }
function renderXdata( $input, $argv, &$parser ) { // Code that does something, such as retrieving data from a database or flat file }
Filip Send instant messages to your online friends http://uk.messenger.yahoo.com
If it's run serially, is there a way to run them in parallel?
They are run serially - probably in the order specified. You can't get "them" to run in parallel, but you could implement your own parallelism.
For example, instead of renderXdata() being the extension function itself, put another function in front: --------------------------------- $wgHooks['ParserBeforeTidy'][] = 'renderXdata'; $wgExtensionFunctions[] = 'wfXdataExtension';
function wfXdataExtension() { global $wgParser; $wgParser->setHook( "xdata", "enqueueXdata" ); }
function enqueueXdata( $input, $argv, &$parser ) { global $wgXDataQueue; // Code that puts items into the $wgXDataQueue for later parallel processing. // Return value should be a unique string used to later inject the correct results }
function renderXdata( $parser, &$text ) { global $wgXDataQueue; // Loop through the Queue, kicking off parallel (asynchronous) requests // As results come back, replace the unique markers in $text with the results // Code that does something, such as retrieving data from a database or flat file } ---------------------------------
Disclaimer: Others may have a better solution - this is just one guy's opinion ;)
-- Jim R. Wilson (jimbojw)
On 7/26/07, Flip Mozart flipmozart@yahoo.com wrote:
Hi!
I wrote the code below for a custom tag <xdata>. This tag can appear more than once in the same article.
Suppose the custom tag appears exactly 5 times in an article. It appears that the renderXdata() function below would be invoked 5 times too. My question is: Is this function called (executed) serially or in parallel?
If it's run serially, is there a way to run them in parallel?
function wfXdataExtension() { global $wgParser; $wgParser->setHook( "xdata", "renderXdata" ); }
function renderXdata( $input, $argv, &$parser ) { // Code that does something, such as retrieving data from a database or flat file }
Filip Send instant messages to your online friends http://uk.messenger.yahoo.com _______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org