locking items in a collection

T

Tim Keith

I have a collection of 10 named items from which I would like
to lock 1 to 10 items in a single request. Multiple processes
may request "tokens" from the collection. At any time 1 to 10
items of the collection can be assigned to unique process ids
during which time a lock is held on the token.

Each item must have a specific name, lock requests are made
for a count of items. When items are unlocked, the unlock
request can use either a handle returned by the original
lock request, or in a special case - unlocked by a request
using its ordinal value(1 - 10).

Each of the ten items will be tied to a process id (and possibly
other arbitrary data). When the process terminates the token
can be unlocked so that other processes may request a lock for
the token.

No two requests should be assigned the same token when multiple
requests for tokens occur simulaneously.

Is there a CPAN module that would provides this functionality?
 
C

ctcgag

I have a collection of 10 named items from which I would like
to lock 1 to 10 items in a single request. Multiple processes
may request "tokens" from the collection.

Are "items" and "tokens" the same thing?
At any time 1 to 10
items of the collection can be assigned to unique process ids
during which time a lock is held on the token.

Are you sure it isn't 0 to 10 of them? Is the state of an item being
assigned to a process ids identical to the state of a process holding
a lock on a token, or are those two different actions?

Each item must have a specific name, lock requests are made
for a count of items.

What is the point of them having specific names if they are not
asked for by that specific name? What happens if the count can only
be partially satisfied?

When items are unlocked, the unlock
request can use either a handle returned by the original
lock request, or in a special case - unlocked by a request
using its ordinal value(1 - 10).

Each of the ten items will be tied to a process id (and possibly
other arbitrary data).

What does this mean? Obviously, a process that holds a lock on a token
"knows" that it does so. And a process can contain any aribtrary data,
and therefore can associate it with a token. Is that not sufficient? If
not, what else is required? Does the lock server need to report to other
processes on who own certain locks?

When the process terminates the token
can be unlocked so that other processes may request a lock for
the token.

"Can be" or "must be"? Is autodetection of dead connections allowed, or
mandatory?
No two requests should be assigned the same token when multiple
requests for tokens occur simulaneously.

Is there a CPAN module that would provides this functionality?

I was thinking of DBD::MySQL to work with MySQL lock manager (which
let's you coordinate locking of arbitrary string tokens), but it appears
that any connection can only hold one lock at a time. That means each
client would need upto 10 separate connections, which would not be very
efficient.

Are all the processes going to run ont the same machine? Are they all
going to be started by forking? Or by threads? Or independently?

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top