org.objectweb.perseus.concurrency.pessimistic

Class RWFifoLock


public final class RWFifoLock
extends Lock

A lock associated to an oid (see the "locks" map within the pessimistic concurrency manager). Provides "one writer/multiple readers" concurrency policy with a FIFO scheduling.

Author:
E. Bruneton, P. Dechamboux, S.Chassande-Barrioz

Field Summary

protected static LockValue
LOCKS
protected Semaphore
semaphore

Fields inherited from class org.objectweb.perseus.concurrency.pessimistic.Lock

dg, hints, logger, reservations

Constructor Summary

RWFifoLock()
RWFifoLock(Object hints, DependencyGraph dg)

Method Summary

boolean
close(Object task)
Removes the given context from the reader and writer lists of this lock.
byte
getMax()
void
readIntention(Object task)
Acquires this lock in read mode for the given context.
void
writeIntention(Object task)
Acquires this lock in write mode for the given context.

Methods inherited from class org.objectweb.perseus.concurrency.pessimistic.Lock

close, getMax, readIntention, reserve, writeIntention

Field Details

LOCKS

protected static final LockValue LOCKS


semaphore

protected final Semaphore semaphore

Constructor Details

RWFifoLock

public RWFifoLock()


RWFifoLock

public RWFifoLock(Object hints,
                  DependencyGraph dg)

Method Details

close

public boolean close(Object task)
Removes the given context from the reader and writer lists of this lock.
Overrides:
close in interface Lock

Parameters:
task - a context

Returns:
true if the reader and writer list are empty, after the context has been removed from these lists. In such a case, this object can be removed from the 'locks' map.


getMax

public byte getMax()
Overrides:
getMax in interface Lock


readIntention

public void readIntention(Object task)
            throws ConcurrencyException
Acquires this lock in read mode for the given context. This method blocks until the lock can be acquired in read mode by this context.
Overrides:
readIntention in interface Lock

Parameters:
task - a context.


writeIntention

public void writeIntention(Object task)
            throws ConcurrencyException
Acquires this lock in write mode for the given context. This method blocks until the lock can be acquired in write mode by this context.
Overrides:
writeIntention in interface Lock

Parameters:
task - a context.


Copyright © 2000-2002 France Telecom S.A., INRIA, IMAG-LSR All Rights Reserved.