memoryio/memoryio-macosx — pull request #20 by zgiles (2013-10-21 15:55:26+00:00)
Title: Image ratelimiting / debouncing

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.