Re: Fetching in a thread

Lachlan Deck <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi Michael,

On 03/05/2007, at 1:18 PM, Michael Deninger wrote:

> I am working on optimizing an application I work with and wanted to  
> know if anyone has successfully done the following:
>
> 1) Given that knowing which records the user is currently working  
> with I can predict which records they will soon want and
> 2) Fetching and sorting those records can take several (2-10)  
> seconds and otherwise interrupts their workflow
>
> Can I create a separate java thread to fetch those records to the  
> default editing context and sort them so that when the user  
> requests them, they appear almost instantly?

Sure. As long as you use appropriate locking... but perhaps it'd make  
sense to use child editing contexts per page and, as such, per  
prediction [i.e., available component actions]. Each of these child  
ecs can have the default ec as their parent.

This way your predictive ec is virtually ready to use by the time  
your component action is hit - being passed to the page prior to  
return such as:
WOComponent nextPage = ( WOComponent )pageWithName 
( SomePage.class.getName() );
nextPage.takeValueForKey( predictedEc, "workingContext" );

Or something along those lines.

Perhaps if you had a PredictiveEditingContext subclass of  
EOEditingContext (which was instantiated with appropriate prediction  
info) then it wouldn't matter if its predictive worker thread had  
completed or not prior to the component action being called.

Just my first impressions...

with regards,
--

Lachlan Deck
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.