The background loader algorithm

Here’s a prototype of the background loader algorithm:

int N = number of image;
int cur = pointer to current image;
bool going_forward = current direction
int max_memory = maximum memory for luce
int cur_memory = current used memory
bool async_load = do async/sync load

flag_loadable_neighbours(cur_memory, max_memory);
next=cur;
prev=cur;
for(i=0;i<N/2;i++)
{
async_load=!i;
if(!ThumbIsLoaded(next) && ThumbIsLoadable(next) && !ThumbIsLoading(next))
LoadThumb(next,async_load);
if(!ScreenIsLoaded(next) && ScreenIsLoadable(next) && !ScreenIsLoading(next))
LoadScreen(next,async_load);
if(!ThumbIsLoaded(prev) && ThumbIsLoadable(prev) && !ThumbIsLoading(prev))
LoadThumb(next,async_load);
if(NeedToBreak())
break; //usually triggered by a keypress
if(going_forward())
next=cur->next; prev=cur->prev;
else
next=cur->prev; prev=cur->next;
}

Advertisements

One Response to The background loader algorithm

  1. Hi there, this weekend is pleasant for me, for the reason that this moment i am reading this impressive
    informative post here at my home.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: