mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 14:02:32 +01:00
334 lines
5.5 KiB
C++
334 lines
5.5 KiB
C++
/* Copyright (C) 2003 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#ifndef UTIL_LOCK_HPP
|
|
#define UTIL_LOCK_HPP
|
|
|
|
#include "SignalData.hpp"
|
|
|
|
class UtilLockReq {
|
|
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class Dbdih;
|
|
friend class MutexManager;
|
|
|
|
friend bool printUTIL_LOCK_REQ(FILE *, const Uint32 *, Uint32, Uint16);
|
|
public:
|
|
STATIC_CONST( SignalLength = 4 );
|
|
|
|
enum RequestInfo {
|
|
TryLock = 1
|
|
};
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
Uint32 requestInfo;
|
|
};
|
|
|
|
class UtilLockConf {
|
|
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class Dbdih;
|
|
friend class MutexManager;
|
|
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
friend bool printUTIL_LOCK_CONF(FILE *, const Uint32 *, Uint32, Uint16);
|
|
public:
|
|
STATIC_CONST( SignalLength = 4 );
|
|
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
Uint32 lockKey;
|
|
};
|
|
|
|
class UtilLockRef {
|
|
|
|
/**
|
|
* Reciver
|
|
*/
|
|
friend class Dbdih;
|
|
friend class MutexManager;
|
|
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
friend bool printUTIL_LOCK_REF(FILE *, const Uint32 *, Uint32, Uint16);
|
|
public:
|
|
STATIC_CONST( SignalLength = 4 );
|
|
|
|
enum ErrorCode {
|
|
OK = 0,
|
|
NoSuchLock = 1,
|
|
OutOfLockRecords = 2,
|
|
DistributedLockNotSupported = 3,
|
|
LockAlreadyHeld = 4
|
|
|
|
};
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
Uint32 errorCode;
|
|
};
|
|
|
|
class UtilUnlockReq {
|
|
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class Dbdih;
|
|
friend class MutexManager;
|
|
|
|
friend bool printUTIL_UNLOCK_REQ(FILE *, const Uint32 *, Uint32, Uint16);
|
|
public:
|
|
STATIC_CONST( SignalLength = 4 );
|
|
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
Uint32 lockKey;
|
|
};
|
|
|
|
class UtilUnlockConf {
|
|
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class Dbdih;
|
|
friend class MutexManager;
|
|
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
friend bool printUTIL_UNLOCK_CONF(FILE *, const Uint32 *, Uint32, Uint16);
|
|
public:
|
|
STATIC_CONST( SignalLength = 3 );
|
|
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
};
|
|
|
|
class UtilUnlockRef {
|
|
|
|
/**
|
|
* Reciver
|
|
*/
|
|
friend class Dbdih;
|
|
friend class MutexManager;
|
|
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
friend bool printUTIL_UNLOCK_REF(FILE *, const Uint32 *, Uint32, Uint16);
|
|
public:
|
|
STATIC_CONST( SignalLength = 4 );
|
|
|
|
enum ErrorCode {
|
|
OK = 0,
|
|
NoSuchLock = 1,
|
|
NotLockOwner = 2
|
|
};
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
Uint32 errorCode;
|
|
};
|
|
|
|
/**
|
|
* Creating a lock
|
|
*/
|
|
class UtilCreateLockReq {
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class MutexManager;
|
|
|
|
friend bool printUTIL_CREATE_LOCK_REQ(FILE *, const Uint32*, Uint32, Uint16);
|
|
public:
|
|
enum LockType {
|
|
Mutex = 0 // Lock with only exclusive locks
|
|
};
|
|
|
|
STATIC_CONST( SignalLength = 4 );
|
|
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
Uint32 lockType;
|
|
};
|
|
|
|
class UtilCreateLockRef {
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class MutexManager;
|
|
|
|
friend bool printUTIL_CREATE_LOCK_REF(FILE *, const Uint32*, Uint32, Uint16);
|
|
public:
|
|
enum ErrorCode {
|
|
OK = 0,
|
|
OutOfLockQueueRecords = 1,
|
|
LockIdAlreadyUsed = 2,
|
|
UnsupportedLockType = 3
|
|
};
|
|
|
|
STATIC_CONST( SignalLength = 4 );
|
|
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
Uint32 errorCode;
|
|
};
|
|
|
|
class UtilCreateLockConf {
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class MutexManager;
|
|
|
|
friend bool printUTIL_CREATE_LOCK_CONF(FILE*, const Uint32*, Uint32, Uint16);
|
|
public:
|
|
STATIC_CONST( SignalLength = 3 );
|
|
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
};
|
|
|
|
/**
|
|
* Creating a lock
|
|
*/
|
|
class UtilDestroyLockReq {
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class MutexManager;
|
|
|
|
friend bool printUTIL_DESTROY_LOCK_REQ(FILE *, const Uint32*, Uint32, Uint16);
|
|
public:
|
|
STATIC_CONST( SignalLength = 4 );
|
|
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
Uint32 lockKey;
|
|
};
|
|
|
|
class UtilDestroyLockRef {
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class MutexManager;
|
|
|
|
friend bool printUTIL_DESTROY_LOCK_REF(FILE *, const Uint32*, Uint32, Uint16);
|
|
public:
|
|
enum ErrorCode {
|
|
OK = 0,
|
|
NoSuchLock = 1,
|
|
NotLockOwner = 2
|
|
};
|
|
|
|
STATIC_CONST( SignalLength = 4 );
|
|
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
Uint32 errorCode;
|
|
};
|
|
|
|
class UtilDestroyLockConf {
|
|
/**
|
|
* Sender
|
|
*/
|
|
friend class DbUtil;
|
|
|
|
/**
|
|
* Receiver
|
|
*/
|
|
friend class MutexManager;
|
|
|
|
friend bool printUTIL_DESTROY_LOCK_CONF(FILE*, const Uint32*, Uint32, Uint16);
|
|
public:
|
|
STATIC_CONST( SignalLength = 3 );
|
|
|
|
private:
|
|
Uint32 senderData;
|
|
Uint32 senderRef;
|
|
Uint32 lockId;
|
|
};
|
|
|
|
#endif
|