Skip to content

Image ratelimiting / debouncing - #20

Closed
zgiles wants to merge 1 commit into
memoryio:masterfrom
zgiles:ratelimiting
Closed

Image ratelimiting / debouncing#20
zgiles wants to merge 1 commit into
memoryio:masterfrom
zgiles:ratelimiting

Conversation

@zgiles

@zgiles zgiles commented Oct 21, 2013

Copy link
Copy Markdown
Contributor

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

zgiles commented Nov 1, 2013

Copy link
Copy Markdown
Contributor Author

Curious if this is going to get merged in..

@jacobrosenthal

Copy link
Copy Markdown
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
jacobrosenthal force-pushed the master branch 2 times, most recently from 99faf7d to 1fb02cf Compare July 22, 2016 23:11
@jacobrosenthal

Copy link
Copy Markdown
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