
// CosConcurrency Control Module, p 7-8 CORBAservices, 
// Concurrency Control Service V1.0, 3/94

#include <CosTransactions.idl>

#pragma prefix "omg.org"

module CosConcurrencyControl {

    enum lock_mode {
        read,
        write,
        upgrade,
        intention_read,
        intention_write
    };

    exception LockNotHeld{};

    interface LockCoordinator
    {
                void drop_locks();
    };

    interface LockSet
    {
        void lock(in lock_mode mode);
        boolean try_lock(in lock_mode mode);

        void unlock(in lock_mode mode)
            raises(LockNotHeld);
        void change_mode(in lock_mode held_mode,
                         in lock_mode new_mode)
           raises(LockNotHeld);
        LockCoordinator get_coordinator(
            in CosTransactions::Coordinator which);
    };

    interface TransactionalLockSet
    {
        void lock(in CosTransactions::Coordinator current,
                  in lock_mode mode);
        boolean try_lock(in CosTransactions::Coordinator current,
                         in lock_mode mode);
        void unlock(in CosTransactions::Coordinator current,
                    in lock_mode mode)
           raises(LockNotHeld);
        void change_mode(in CosTransactions::Coordinator current,
                         in lock_mode held_mode,
                         in lock_mode new_mode)
           raises(LockNotHeld);
        LockCoordinator get_coordinator(
            in CosTransactions::Coordinator which);
    };

    interface LockSetFactory
    {
        LockSet create();
        LockSet create_related(in LockSet which);
        TransactionalLockSet create_transactional();
        TransactionalLockSet create_transactional_related(in
            TransactionalLockSet which);
    };
};

