Monday, April 04, 2011 at 1:06 AM.


on readAllFeeds (adrctfeeds=nil) {
		<<3/31/11; 5:16:59 PM by DW
			<<Stats table counter of number of feeds read this scan.
		<<3/28/11; 7:55:06 AM by DW
			<<Minor code cleanup.
		<<10/6/10; 6:04:41 PM by DW
			<<New routine. Read all the feeds, but instead of reading them serially, read them in parallel. Maintain an array of thread ids, and as they complete, add new ones, until we're done.
	local (adrdata = river2suite.init (), adrfeed, maxthreads = adrdata^.prefs.maxThreads, id, i);
	local (adrthreads = @system.temp.river2.threads);
	new (tabletype, adrthreads);
	system.temp.river2.ctFeedsReadThisScan = 0;
	adrdata^.stats.ctFeedsReadThisScan = 0; //3/31/11 by DW
	for adrfeed in @adrdata^.feeds {
		id = thread.callscript (@river2Suite.readFeed, {nameof (adrfeed^)});
		adrthreads^.[id] = ();
		while sizeof (adrthreads^) >= maxthreads { //wait for at least one slot to be open
			thread.sleepticks (15);
			for i = sizeof (adrthreads^) downto 1 {
				if not thread.exists (nameof (adrthreads^ [i])) { //thread has terminated
					delete (adrthreads^ [i])}}};
	if adrctfeeds != nil {
		adrctfeeds^ = sizeof (adrdata^.feeds)};
	delete (adrthreads);
	delete (@system.temp.river2.ctFeedsReadThisScan)};
bundle { //test code
	readallfeeds ()}

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.