I think that the crux of Mahadev's suggestion is that you do as you say, but
you should try the resources in randomized order.
That will have very robust properties, especially with more than a handful
of resources and is easy to code and to analyze.
It won't work if you really mean "lock first available from this sequence".
On Tue, Feb 23, 2010 at 4:05 AM, Martin Waite <waite....@googlemail.com>wrote:
> For locking, I could loop through
> the available ids, attempting to create a lock for that in the locked
> directory. However this seems a bit clumsy and slow. Also, the locks are
> held for a relatively short time (1 second on average), and by time I have
> blundered through all the possible locks, ids that were locked at the start
> might be available by time I finished.
Ted Dunning, CTO