ActionQueue execution delay.

1 view
Skip to first unread message

andyhatch

unread,
Aug 26, 2009, 12:08:58 PM8/26/09
to bumpslide, b...@benmcmaster.com
I'm using the LoaderQueue class now in an app that has a lot of images
loading at init. This load, even though it is in the queue, seems to
be competing with other simultaneous loads on the site. I was
thinking that putting a 200ms delay between requests in the queue
could decrease competition for bandwidth and make for a smoother
load. This would be in addition to limiting the thread count in the
ActionQueue.

For now I'm extending ActionQueue class to put a delay between
executed actions. Is this a feature that could be added to the
ActionQueue class or is there a better way of doing this?

David Knape

unread,
Aug 28, 2009, 7:00:53 PM8/28/09
to bump...@googlegroups.com
The browser limits the number of simultaneous requests, but if you set
the thread count on the action queue to 1, other simultaneous requests
should still get through.

As for adding a delay, there is already a delay in the ActionQueue
class method 'run'. It is currently hard-coded for 10ms, but this
could easily be turned into a configurable parameter or patched to add
a longer delay if that is what you desire.

Let me know if things are behaving strangely.

Thanks.

-dk

--
David Knape
Programmer / Consultant
http://bumpslide.com/

andyhatch

unread,
Aug 31, 2009, 11:45:22 AM8/31/09
to bumpslide
I noticed the delay in the 'run' method, but that only affects the
start of the ActionQueue, correct. I was trying to put a delay after
the end of one action and before the start of the next.

I ended up extending Action and overriding the 'execute' method as
follows:

override public function execute() : void
{
if(_delay > 0) // delay is a protected var that defaults to 0
Delegate.callLater(_delay, action);
else
super.execute();
}
}


I couldn't extend LoaderQueue because the _queue and _actions
variables are private, so I created a new LoaderQueue class for my own
use and substituted Action with my own extension in the 'load'
method. Would be nice if LoaderQueue was extensible with protected
instead of private vars.



On Aug 28, 7:00 pm, David Knape <tkd...@gmail.com> wrote:
> The browser limits the number of simultaneous requests, but if you set
> the thread count on the action queue to 1, other simultaneous requests
> should still get through.
>
> As for adding a delay, there is already a delay in the ActionQueue
> class method 'run'.  It is currently hard-coded for 10ms, but this
> could easily be turned into a configurable parameter or patched to add
> a longer delay if that is what you desire.
>
> Let me know if things are behaving strangely.
>
> Thanks.
>
> -dk
>
> --
> David Knape
> Programmer / Consultanthttp://bumpslide.com/

David Knape

unread,
Sep 2, 2009, 5:57:07 PM9/2/09
to bump...@googlegroups.com
Actually, I believe the run method is called each time, but I should
double-check that. Your point about making those variables protected
is quite valid. I'll look into that.

Thanks for the feedback. I'm glad you're able to put this code to use.

-dk

--
David Knape
Programmer / Consultant
http://bumpslide.com/



andyhatch

unread,
Sep 3, 2009, 4:07:11 PM9/3/09
to bumpslide
Saw r191. Thanks!


On Sep 2, 5:57 pm, David Knape <tkd...@gmail.com> wrote:
> Actually, I believe the run method is called each time, but I should
> double-check that.  Your point about making those variables protected
> is quite valid.  I'll look into that.
>
> Thanks for the feedback.  I'm glad you're able to put this code to use.
>
> -dk
>
> --
> David Knape
> Programmer / Consultanthttp://bumpslide.com/

andyhatch

unread,
Sep 3, 2009, 4:08:21 PM9/3/09
to bumpslide
Also, can you let me know what the verdict is on the run method?
Reply all
Reply to author
Forward
0 new messages