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

feedhoseSuite.waitForContent

on waitForContent (hosename, pta, seed, adritems, timeoutsecs=nil) {
	<<Changes
		<<12/7/10; 4:48:53 PM by DW
			<<Add an item to the log when we return.
		<<9/30/10; 8:07:05 PM by DW
			<<Add timeoutsecs param.
		<<9/29/10; 12:29:52 PM by DW
			<<Add hosename parameter.
		<<9/25/10; 6:04:26 PM by DW
			<<Created. 
	local (adrdata = feedHoseSuite.init (), id = thread.getcurrentid (), items, startticks = clock.ticks ());
	local (adrhose = feedhosesuite.inithose (hosename), domain = tcp.dns.getdomainname (pta^.client));
	local (adrthreadtable = @system.temp.feedHose.server.waitingThreads.[hosename].[id], ctitems);
	new (tabletype, adrthreadtable);
	bundle { //deal with timeoutsecs
		if timeoutsecs == nil {
			timeoutsecs = adrdata^.server.prefs.timeoutSecs}
		else {
			if timeoutsecs > adrdata^.server.prefs.timeoutSecs {
				timeoutsecs = adrdata^.server.prefs.timeoutSecs}
			else {
				if timeoutsecs < 1 {
					timeoutsecs = 1}}}};
	adrthreadtable^.ip = domain;
	adrthreadtable^.expires = clock.now () + timeoutsecs;
	adrthreadtable^.seed = seed;
	thread.sleepfor (timeoutsecs);
	thread.sleepfor (1); //an experiment --12/8/10 by DW
	feedhoseSuite.getBackItems (hosename, seed, adritems, startticks, @ctitems);
	<<scratchpad.wfcitems = adritems^
	try {delete (adrthreadtable)};
	bundle { //log the call -- 12/7/10 by DW
		if ctitems > 0 {
			log2.add ("FeedHose", "Long-poll", "Returned " + ctitems + " <i>" + hosename + "</i> FeedHose item(s) to caller <i>" + domain + "</i> with a timeout of " + timeoutsecs + " seconds.", startticks)}};
	return (true)}



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.