Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image ratelimiting / debouncing #20

Closed
wants to merge 1 commit into from

Conversation

zgiles
Copy link
Contributor

@zgiles zgiles commented Oct 21, 2013

Adding a blocking function to prevent multiple callbacks at the same
time (or close together) from causing either a) a function to throw an
exception because an object is busy doing something already, b) getting
into code where it looked like something was available but isn't now,
or c) multiple pictures within a few seconds.

This blocking is simple and works by creating a synchronization group
which controls a BOOL so that only one call can edit the BOOL at the
same time. It also sets a timer in another thread to reset the BOOL
after some time (10seconds for now) so that we have up to 10s of
unlimited bad calls against the function before another one wins.

The logs state when a thread tried and won or lost.

An earlier commit to make the 2.0f delay standard across the board
helped here. Everything including the menubar call go through to ensure
nothing fights with each other.

Adding a blocking function to prevent multiple callbacks at the same
time (or close together) from causing either a) a function to throw an
exception because an object is busy doing something already, b) getting
into code where it looked like something was available but isn't now,
or c) multiple pictures within a few seconds.

This blocking is simple and works by creating a synchronization group
which controls a BOOL so that only one call can edit the BOOL at the
same time. It also sets a timer in another thread to reset the BOOL
after some time (10seconds for now) so that we have up to 10s of
unlimited bad calls against the function before another one wins.

The logs state when a thread tried and won or lost.

An earlier commit to make the 2.0f delay standard across the board
helped here. Everything including the menubar call go through to ensure
nothing fights with each other.
@zgiles
Copy link
Contributor Author

zgiles commented Nov 1, 2013

Curious if this is going to get merged in..

@jacobrosenthal
Copy link
Member

We don't need this until we process adding other triggers for photos in #21

As such I'm still actively evaluating this. Does it help with our existing bug #24 for some reason I can't fathom? Is this the best way to do blocking?

@jacobrosenthal
Copy link
Member

I think switching to nscontrol queues finally licked this. 1979edc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants