package simpledb;

/**
 * Interface for a generic deadlock detector, independent of its
 * mechanism for detection.
 *
 * The lock manager calls the waitingForLock, lockAcquired, and
 * transactionComplete functions at the appropriate times to notify
 * the deadlock detector of lock status. If a deadlock is detected,
 * some appropriate transaction is aborted by setting a flag and
 * interrupting the transaction's thread. The thread should then check
 * whether it has been aborted (or whether it was interrupted for some
 * other reason) by calling isTransactionAborted.
 *
 * @author <a href="mailto:drkp@mit.edu">Dan R. K. Ports</a>
 */
public interface DeadlockDetector {
    public void waitingForLock(PageId pid, TransactionId tid,
                               boolean exclusive);
    public void lockAcquired(PageId pid, TransactionId tid);
    public void transactionComplete(TransactionId tid,
                                     boolean commit);
    public boolean isTransactionAborted(TransactionId tid);
}
