enthought / tabs

Default Repo description from terraform module
0 stars 0 forks source link

Avoid queuing multiple frames at once. #88

Closed johntyree closed 8 years ago

johntyree commented 8 years ago

Keeping in line with the sweeping performance improvements of the last two weeks, this PR prevents multiple asynchronous requests from building up when the slider is being moved around.

I'd call it a state machine, but there wasn't really enough to map it out properly. Essentially it works like this:

  1. If the slider moves, assign the current value to a variable (overwriting whatever is there) and set the system to SYNC mode. If the system was STOPPED, we start it.
  2. If the space bar is pressed or the TABSControl is clicked, set the system to FOREVER mode. If the system was STOPPED, we start it.

While running, we check if the system state is STOPPED. If so, we return immediately and the loop breaks. Otherwise, we load whatever frame is currently in the variable. If we ever discover that the current frame and the variable match, we set the system to STOPPED, unless we were in FOREVER mode, at which time we set the variable to current + 1.

kjordahl commented 8 years ago

Oh, thanks, I was just looking at fixing that merge conflict.

The fps counter is a bit wonky now, but that's not too important.

LGTM otherwise.

johntyree commented 8 years ago

The FPS counter is relying on the frame number, which changes randomly if you're moving the slider around.

johntyree commented 8 years ago

We could track that better, but it's not really useful if you're not in RUN_FOREVER mode anyway.