cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robby Pelssers <Robby.Pelss...@nxp.com>
Subject RE: does flowscript also support sht like setTimeout and setInterval ?? [SOLVED]
Date Thu, 24 May 2012 13:58:21 GMT
I found a nice article on stackoverflow showing how to create my own implementation in flowscript.
 I will of course first need to thoroughly test it but it looks promising so far ;-)

var setTimeout,
    clearTimeout,
    setInterval,
    clearInterval;

(function () {
    var timer = new java.util.Timer();
    var counter = 1;
    var ids = {};

    setTimeout = function (fn,delay) {
        var id = counter++;
        ids[id] = new JavaAdapter(java.util.TimerTask,{run: fn});
        timer.schedule(ids[id],delay);
        return id;
    }

    clearTimeout = function (id) {
        ids[id].cancel();
        timer.purge();
        delete ids[id];
    }

    setInterval = function (fn,delay) {
        var id = counter++;
        ids[id] = new JavaAdapter(java.util.TimerTask,{run: fn});
        timer.schedule(ids[id],delay,delay);
        return id;
    }

    clearInterval = clearTimeout;

})();
From: Robby Pelssers [mailto:Robby.Pelssers@nxp.com]
Sent: Thursday, May 24, 2012 2:56 PM
To: dev@cocoon.apache.org
Subject: does flowscript also support sht like setTimeout and setInterval ??

Hi guys,

I was bulk processing DITA maps and topics from flowscript and noticed that following code
is executed parallel.  So basically the cocoon.processPipelineTo returns immediately so it
seems.  This results in max sessions reached to XMLDb and I run into an exception.  Just checking
what is best way to put some delay in the execution.

function generateValuePropositions() {
   var id_collection = Collection.fromArray(getJson('getCommaSeparatedBasicTypeIds'));
   print('Starting generation of ' + id_collection.getLength() + ' value propositions!!');
   id_collection.forEach(
       /** we write the map and topics for each id **/
       function(id){
           cocoon.processPipelineTo("write-map-and-topics/" + id, null, new Packages.java.io.ByteArrayOutputStream());
       }
   );
}

Kind regards,
Robby

Mime
View raw message