kccommon.h   kccommon.h 
skipping to change at line 112 skipping to change at line 112
#endif #endif
#undef VERSION #undef VERSION
#undef LIBVER #undef LIBVER
#undef LIBREV #undef LIBREV
#undef SYSNAME #undef SYSNAME
#undef BIGEND #undef BIGEND
#undef CLOCKTICK #undef CLOCKTICK
#undef PAGESIZE #undef PAGESIZE
#undef SUCCESS
#undef NOIMPL
#undef INVALID
#undef NOREPOS
#undef NOPERM
#undef BROKEN
#undef DUPREC
#undef NOREC
#undef LOGIC
#undef SYSTEM
#undef MISC
#undef DEBUG
#undef INFO
#undef WARN
#undef ERROR
#undef OPEN
#undef CLOSE
#undef CLEAR
#undef ITERATE
#undef SYNCHRONIZE
#undef BEGINTRAN
#undef COMMITTRAN
#undef ABORTTRAN
#if defined(_KCUYIELD) #if defined(_KCUYIELD)
#if defined(_MSC_VER) #if defined(_MSC_VER)
#include <windows.h> #include <windows.h>
#define _yield_() ::Sleep(0) #define _yield_() ::Sleep(0)
#else #else
#include <sched.h> #include <sched.h>
#define _yield_() ::sched_yield() #define _yield_() ::sched_yield()
#endif #endif
#define _testyield_() \ #define _testyield_() \
do { \ do { \
 End of changes. 1 change blocks. 
0 lines changed or deleted 25 lines changed or added


 kcdirdb.h   kcdirdb.h 
skipping to change at line 43 skipping to change at line 43
*/ */
namespace { namespace {
const char* DDBMAGICFILE = "__KCDIR__"; ///< magic file of the directory const char* DDBMAGICFILE = "__KCDIR__"; ///< magic file of the directory
const char* DDBMETAFILE = "__meta__"; ///< meta data file of the directo ry const char* DDBMETAFILE = "__meta__"; ///< meta data file of the directo ry
const char* DDBOPAQUEFILE = "__opq__"; ///< opaque file of the directory const char* DDBOPAQUEFILE = "__opq__"; ///< opaque file of the directory
const char* DDBATRANPREFIX = "_x"; ///< prefix of files for auto tran saction const char* DDBATRANPREFIX = "_x"; ///< prefix of files for auto tran saction
const char DDBCHKSUMSEED[] = "__kyotocabinet__"; ///< seed of the module c hecksum const char DDBCHKSUMSEED[] = "__kyotocabinet__"; ///< seed of the module c hecksum
const char DDBMAGICEOF[] = "_EOF_"; ///< magic data for the end of fil e const char DDBMAGICEOF[] = "_EOF_"; ///< magic data for the end of fil e
const int64_t DDBMETABUFSIZ = 128; ///< size of the meta data buffer const int64_t DDBMETABUFSIZ = 128; ///< size of the meta data buffer
const uint8_t DDBRECMAGIC = 0xcc; ///< magic data for record const uint8_t DDBRECMAGIC = 0xcc; ///< magic data for record
const int32_t DDBRLOCKSLOT = 256; ///< number of slots of the record lock const int32_t DDBRLOCKSLOT = 8192; ///< number of slots of the record lock
const int32_t DDBRECUNITSIZ = 32; ///< unit size of a record const int32_t DDBRECUNITSIZ = 32; ///< unit size of a record
const size_t DDBOPAQUESIZ = 16; ///< size of the opaque buffer const size_t DDBOPAQUESIZ = 16; ///< size of the opaque buffer
const char* DDBWALPATHEXT = "wal"; ///< extension of the WAL director y const char* DDBWALPATHEXT = "wal"; ///< extension of the WAL director y
const char* DDBTMPPATHEXT = "tmp"; ///< extension of the temporary di rectory const char* DDBTMPPATHEXT = "tmp"; ///< extension of the temporary di rectory
} }
/** /**
* Directory hash database. * Directory hash database.
* @note This class is a concrete class to operate a hash database in a dir ectory. This class * @note This class is a concrete class to operate a hash database in a dir ectory. This class
* can be inherited but overwriting methods is forbidden. Before every dat abase operation, it is * can be inherited but overwriting methods is forbidden. Before every dat abase operation, it is
skipping to change at line 373 skipping to change at line 373
* Status flags. * Status flags.
*/ */
enum Flag { enum Flag {
FOPEN = 1 << 0, ///< dummy for compatibility FOPEN = 1 << 0, ///< dummy for compatibility
FFATAL = 1 << 1 ///< dummy for compatibility FFATAL = 1 << 1 ///< dummy for compatibility
}; };
/** /**
* Default constructor. * Default constructor.
*/ */
explicit DirDB() : explicit DirDB() :
mlock_(), rlock_(), error_(), logger_(NULL), logkinds_(0), mtrigger_(NU LL), mlock_(), rlock_(DDBRLOCKSLOT), error_(), logger_(NULL), logkinds_(0), mtrigger_(NULL),
omode_(0), writer_(false), autotran_(false), autosync_(false), recov_(f alse), reorg_(false), omode_(0), writer_(false), autotran_(false), autosync_(false), recov_(f alse), reorg_(false),
file_(), curs_(), path_(""), file_(), curs_(), path_(""),
libver_(LIBVER), librev_(LIBREV), fmtver_(FMTVER), chksum_(0), type_(TY PEDIR), libver_(LIBVER), librev_(LIBREV), fmtver_(FMTVER), chksum_(0), type_(TY PEDIR),
flags_(0), opts_(0), count_(0), size_(0), opaque_(), embcomp_(&ZLIBRAWC OMP), comp_(NULL), flags_(0), opts_(0), count_(0), size_(0), opaque_(), embcomp_(&ZLIBRAWC OMP), comp_(NULL),
tran_(false), trhard_(false), trcount_(0), trsize_(0), walpath_(""), tm ppath_("") { tran_(false), trhard_(false), trcount_(0), trsize_(0), walpath_(""), tm ppath_("") {
_assert_(true); _assert_(true);
} }
/** /**
* Destructor. * Destructor.
* @note If the database is not closed, it is closed implicitly. * @note If the database is not closed, it is closed implicitly.
skipping to change at line 2156 skipping to change at line 2156
int64_t size_impl() { int64_t size_impl() {
return size_ + count_ * DDBRECUNITSIZ; return size_ + count_ * DDBRECUNITSIZ;
} }
/** Dummy constructor to forbid the use. */ /** Dummy constructor to forbid the use. */
DirDB(const DirDB&); DirDB(const DirDB&);
/** Dummy Operator to forbid the use. */ /** Dummy Operator to forbid the use. */
DirDB& operator =(const DirDB&); DirDB& operator =(const DirDB&);
/** The method lock. */ /** The method lock. */
SpinRWLock mlock_; SpinRWLock mlock_;
/** The record locks. */ /** The record locks. */
SlottedSpinRWLock<DDBRLOCKSLOT> rlock_; SlottedSpinRWLock rlock_;
/** The last happened error. */ /** The last happened error. */
TSD<Error> error_; TSD<Error> error_;
/** The internal logger. */ /** The internal logger. */
Logger* logger_; Logger* logger_;
/** The kinds of logged messages. */ /** The kinds of logged messages. */
uint32_t logkinds_; uint32_t logkinds_;
/** The internal meta operation trigger. */ /** The internal meta operation trigger. */
MetaTrigger* mtrigger_; MetaTrigger* mtrigger_;
/** The open mode. */ /** The open mode. */
uint32_t omode_; uint32_t omode_;
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 kchashdb.h   kchashdb.h 
skipping to change at line 56 skipping to change at line 56
const int64_t HDBMOFFFLAGS = 24; ///< offset of the status flags const int64_t HDBMOFFFLAGS = 24; ///< offset of the status flags
const int64_t HDBMOFFCOUNT = 32; ///< offset of the record number const int64_t HDBMOFFCOUNT = 32; ///< offset of the record number
const int64_t HDBMOFFSIZE = 40; ///< offset of the file size const int64_t HDBMOFFSIZE = 40; ///< offset of the file size
const int64_t HDBMOFFOPAQUE = 48; ///< offset of the opaque data const int64_t HDBMOFFOPAQUE = 48; ///< offset of the opaque data
const int64_t HDBHEADSIZ = 64; ///< size of the header const int64_t HDBHEADSIZ = 64; ///< size of the header
const int32_t HDBFBPWIDTH = 6; ///< width of the free block const int32_t HDBFBPWIDTH = 6; ///< width of the free block
const int32_t HDBWIDTHLARGE = 6; ///< large width of the record add ress const int32_t HDBWIDTHLARGE = 6; ///< large width of the record add ress
const int32_t HDBWIDTHSMALL = 4; ///< small width of the record add ress const int32_t HDBWIDTHSMALL = 4; ///< small width of the record add ress
const size_t HDBRECBUFSIZ = 48; ///< size of the record buffer const size_t HDBRECBUFSIZ = 48; ///< size of the record buffer
const size_t HDBIOBUFSIZ = 1024; ///< size of the IO buffer const size_t HDBIOBUFSIZ = 1024; ///< size of the IO buffer
const int32_t HDBRLOCKSLOT = 256; ///< number of slots of the record lock const int32_t HDBRLOCKSLOT = 4096; ///< number of slots of the record lock
const uint8_t HDBDEFAPOW = 3; ///< default alignment power const uint8_t HDBDEFAPOW = 3; ///< default alignment power
const uint8_t HDBMAXAPOW = 15; ///< maximum alignment power const uint8_t HDBMAXAPOW = 15; ///< maximum alignment power
const uint8_t HDBDEFFPOW = 10; ///< default free block pool power const uint8_t HDBDEFFPOW = 10; ///< default free block pool power
const uint8_t HDBMAXFPOW = 20; ///< maximum free block pool power const uint8_t HDBMAXFPOW = 20; ///< maximum free block pool power
const int64_t HDBDEFBNUM = 1048583LL; ///< default bucket number const int64_t HDBDEFBNUM = 1048583LL; ///< default bucket number
const int64_t HDBDEFMSIZ = 64LL << 20; ///< default size of the memory-ma pped region const int64_t HDBDEFMSIZ = 64LL << 20; ///< default size of the memory-ma pped region
const uint8_t HDBRECMAGIC = 0xcc; ///< magic data for record const uint8_t HDBRECMAGIC = 0xcc; ///< magic data for record
const uint8_t HDBPADMAGIC = 0xee; ///< magic data for padding const uint8_t HDBPADMAGIC = 0xee; ///< magic data for padding
const uint8_t HDBFBMAGIC = 0xdd; ///< magic data for free block const uint8_t HDBFBMAGIC = 0xdd; ///< magic data for free block
const int32_t HDBDFRGMAX = 512; ///< maximum unit of auto defragme ntation const int32_t HDBDFRGMAX = 512; ///< maximum unit of auto defragme ntation
skipping to change at line 482 skipping to change at line 482
* Status flags. * Status flags.
*/ */
enum Flag { enum Flag {
FOPEN = 1 << 0, ///< whether opened FOPEN = 1 << 0, ///< whether opened
FFATAL = 1 << 1 ///< whether with fatal error FFATAL = 1 << 1 ///< whether with fatal error
}; };
/** /**
* Default constructor. * Default constructor.
*/ */
explicit HashDB() : explicit HashDB() :
mlock_(), rlock_(), flock_(), atlock_(), error_(), mlock_(), rlock_(HDBRLOCKSLOT), flock_(), atlock_(), error_(),
logger_(NULL), logkinds_(0), mtrigger_(NULL), logger_(NULL), logkinds_(0), mtrigger_(NULL),
omode_(0), writer_(false), autotran_(false), autosync_(false), reorg_(f alse), trim_(false), omode_(0), writer_(false), autotran_(false), autosync_(false), reorg_(f alse), trim_(false),
file_(), fbp_(), curs_(), path_(""), file_(), fbp_(), curs_(), path_(""),
libver_(0), librev_(0), fmtver_(0), chksum_(0), type_(TYPEHASH), libver_(0), librev_(0), fmtver_(0), chksum_(0), type_(TYPEHASH),
apow_(HDBDEFAPOW), fpow_(HDBDEFFPOW), opts_(0), bnum_(HDBDEFBNUM), apow_(HDBDEFAPOW), fpow_(HDBDEFFPOW), opts_(0), bnum_(HDBDEFBNUM),
flags_(0), flagopen_(false), count_(0), lsiz_(0), psiz_(0), opaque_(), flags_(0), flagopen_(false), count_(0), lsiz_(0), psiz_(0), opaque_(),
msiz_(HDBDEFMSIZ), dfunit_(0), embcomp_(&ZLIBRAWCOMP), msiz_(HDBDEFMSIZ), dfunit_(0), embcomp_(&ZLIBRAWCOMP),
align_(0), fbpnum_(0), width_(0), linear_(false), align_(0), fbpnum_(0), width_(0), linear_(false),
comp_(NULL), rhsiz_(0), boff_(0), roff_(0), dfcur_(0), frgcnt_(0), comp_(NULL), rhsiz_(0), boff_(0), roff_(0), dfcur_(0), frgcnt_(0),
tran_(false), trhard_(false), trfbp_(), trcount_(0), trsize_(0) { tran_(false), trhard_(false), trfbp_(), trcount_(0), trsize_(0) {
skipping to change at line 3489 skipping to change at line 3489
atlock_.unlock(); atlock_.unlock();
return !err; return !err;
} }
/** Dummy constructor to forbid the use. */ /** Dummy constructor to forbid the use. */
HashDB(const HashDB&); HashDB(const HashDB&);
/** Dummy Operator to forbid the use. */ /** Dummy Operator to forbid the use. */
HashDB& operator =(const HashDB&); HashDB& operator =(const HashDB&);
/** The method lock. */ /** The method lock. */
SpinRWLock mlock_; SpinRWLock mlock_;
/** The record locks. */ /** The record locks. */
SlottedSpinRWLock<HDBRLOCKSLOT> rlock_; SlottedSpinRWLock rlock_;
/** The file lock. */ /** The file lock. */
SpinLock flock_; SpinLock flock_;
/** The auto transaction lock. */ /** The auto transaction lock. */
Mutex atlock_; Mutex atlock_;
/** The last happened error. */ /** The last happened error. */
TSD<Error> error_; TSD<Error> error_;
/** The internal logger. */ /** The internal logger. */
Logger* logger_; Logger* logger_;
/** The kinds of logged messages. */ /** The kinds of logged messages. */
uint32_t logkinds_; uint32_t logkinds_;
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 kcstashdb.h   kcstashdb.h 
skipping to change at line 35 skipping to change at line 35
#include <kcregex.h> #include <kcregex.h>
#include <kcdb.h> #include <kcdb.h>
#include <kcplantdb.h> #include <kcplantdb.h>
namespace kyotocabinet { // common namespace namespace kyotocabinet { // common namespace
/** /**
* Constants for implementation. * Constants for implementation.
*/ */
namespace { namespace {
const int32_t SDBRLOCKSLOT = 256; ///< number of slots of the record lock const int32_t SDBRLOCKSLOT = 1024; ///< number of slots of the record lock
const size_t SDBDEFBNUM = 1048583LL; ///< default bucket number const size_t SDBDEFBNUM = 1048583LL; ///< default bucket number
const size_t SDBOPAQUESIZ = 16; ///< size of the opaque buffer const size_t SDBOPAQUESIZ = 16; ///< size of the opaque buffer
} }
/** /**
* Economical on-memory hash database. * Economical on-memory hash database.
* @note This class is a concrete class to operate a hash database on memor y. This class can be * @note This class is a concrete class to operate a hash database on memor y. This class can be
* inherited but overwriting methods is forbidden. Before every database o peration, it is * inherited but overwriting methods is forbidden. Before every database o peration, it is
* necessary to call the StashDB::open method in order to open a database f ile and connect the * necessary to call the StashDB::open method in order to open a database f ile and connect the
* database object to it. To avoid data missing or corruption, it is impor tant to close every * database object to it. To avoid data missing or corruption, it is impor tant to close every
skipping to change at line 308 skipping to change at line 308
StashDB* db_; StashDB* db_;
/** The index of the current bucket. */ /** The index of the current bucket. */
int64_t bidx_; int64_t bidx_;
/** The buffer of the current record. */ /** The buffer of the current record. */
char* rbuf_; char* rbuf_;
}; };
/** /**
* Default constructor. * Default constructor.
*/ */
explicit StashDB() : explicit StashDB() :
mlock_(), rlock_(), flock_(), error_(), logger_(NULL), logkinds_(0), mt mlock_(), rlock_(SDBRLOCKSLOT), flock_(), error_(),
rigger_(NULL), logger_(NULL), logkinds_(0), mtrigger_(NULL),
omode_(0), curs_(), path_(""), bnum_(SDBDEFBNUM), opaque_(), omode_(0), curs_(), path_(""), bnum_(SDBDEFBNUM), opaque_(),
count_(0), size_(0), buckets_(NULL), count_(0), size_(0), buckets_(NULL),
tran_(false), trlogs_(), trcount_(0), trsize_(0) { tran_(false), trlogs_(), trcount_(0), trsize_(0) {
_assert_(true); _assert_(true);
} }
/** /**
* Destructor. * Destructor.
* @note If the database is not closed, it is closed implicitly. * @note If the database is not closed, it is closed implicitly.
*/ */
~StashDB() { ~StashDB() {
skipping to change at line 801 skipping to change at line 802
if (strmap->count("opaque") > 0) if (strmap->count("opaque") > 0)
(*strmap)["opaque"] = std::string(opaque_, sizeof(opaque_)); (*strmap)["opaque"] = std::string(opaque_, sizeof(opaque_));
if (strmap->count("bnum_used") > 0) { if (strmap->count("bnum_used") > 0) {
int64_t cnt = 0; int64_t cnt = 0;
for (size_t i = 0; i < bnum_; i++) { for (size_t i = 0; i < bnum_; i++) {
if (buckets_[i]) cnt++; if (buckets_[i]) cnt++;
} }
(*strmap)["bnum_used"] = strprintf("%lld", (long long)cnt); (*strmap)["bnum_used"] = strprintf("%lld", (long long)cnt);
} }
(*strmap)["count"] = strprintf("%lld", (long long)count_); (*strmap)["count"] = strprintf("%lld", (long long)count_);
(*strmap)["size"] = strprintf("%lld", (long long)size_); (*strmap)["size"] = strprintf("%lld", (long long)size_impl());
return true; return true;
} }
/** /**
* Create a cursor object. * Create a cursor object.
* @return the return value is the created cursor object. * @return the return value is the created cursor object.
* @note Because the object of the return value is allocated by the const ructor, it should be * @note Because the object of the return value is allocated by the const ructor, it should be
* released with the delete operator when it is no longer in use. * released with the delete operator when it is no longer in use.
*/ */
Cursor* cursor() { Cursor* cursor() {
_assert_(true); _assert_(true);
skipping to change at line 1265 skipping to change at line 1266
} }
} }
} }
/** Dummy constructor to forbid the use. */ /** Dummy constructor to forbid the use. */
StashDB(const StashDB&); StashDB(const StashDB&);
/** Dummy Operator to forbid the use. */ /** Dummy Operator to forbid the use. */
StashDB& operator =(const StashDB&); StashDB& operator =(const StashDB&);
/** The method lock. */ /** The method lock. */
SpinRWLock mlock_; SpinRWLock mlock_;
/** The record locks. */ /** The record locks. */
SlottedSpinRWLock<SDBRLOCKSLOT> rlock_; SlottedSpinRWLock rlock_;
/** The file lock. */ /** The file lock. */
SpinLock flock_; SpinLock flock_;
/** The last happened error. */ /** The last happened error. */
TSD<Error> error_; TSD<Error> error_;
/** The internal logger. */ /** The internal logger. */
Logger* logger_; Logger* logger_;
/** The kinds of logged messages. */ /** The kinds of logged messages. */
uint32_t logkinds_; uint32_t logkinds_;
/** The internal meta operation trigger. */ /** The internal meta operation trigger. */
MetaTrigger* mtrigger_; MetaTrigger* mtrigger_;
 End of changes. 4 change blocks. 
5 lines changed or deleted 5 lines changed or added


 kcthread.h   kcthread.h 
skipping to change at line 61 skipping to change at line 61
void detach(); void detach();
/** /**
* Terminate the running thread. * Terminate the running thread.
*/ */
static void exit(); static void exit();
/** /**
* Yield the processor from the current thread. * Yield the processor from the current thread.
*/ */
static void yield(); static void yield();
/** /**
* Chill the processor by suspending execution for a quick moment.
*/
static void chill();
/**
* Suspend execution of the current thread. * Suspend execution of the current thread.
* @param sec the interval of the suspension in seconds. * @param sec the interval of the suspension in seconds.
* @return true on success, or false on failure. * @return true on success, or false on failure.
*/ */
static bool sleep(double sec); static bool sleep(double sec);
/** /**
* Get the hash value of the current thread. * Get the hash value of the current thread.
* @return the hash value of the current thread. * @return the hash value of the current thread.
*/ */
static int64_t hash(); static int64_t hash();
skipping to change at line 166 skipping to change at line 170
/** Dummy constructor to forbid the use. */ /** Dummy constructor to forbid the use. */
ScopedMutex(const ScopedMutex&); ScopedMutex(const ScopedMutex&);
/** Dummy Operator to forbid the use. */ /** Dummy Operator to forbid the use. */
ScopedMutex& operator =(const ScopedMutex&); ScopedMutex& operator =(const ScopedMutex&);
/** The inner device. */ /** The inner device. */
Mutex* mutex_; Mutex* mutex_;
}; };
/** /**
* Slotted mutex device. * Slotted mutex device.
* @param SLOTNUM the number of slots.
*/ */
template <int32_t SLOTNUM>
class SlottedMutex { class SlottedMutex {
public: public:
/** /**
* Constructor. * Constructor.
* @param slotnum the number of slots.
*/ */
explicit SlottedMutex() : locks_() { explicit SlottedMutex(size_t slotnum);
_assert_(true);
}
/** /**
* Destructor. * Destructor.
*/ */
~SlottedMutex() { ~SlottedMutex();
_assert_(true);
}
/** /**
* Get the lock of a slot. * Get the lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void lock(int32_t idx) { void lock(size_t idx);
_assert_(idx >= 0);
locks_[idx].lock();
}
/** /**
* Release the lock of a slot. * Release the lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void unlock(int32_t idx) { void unlock(size_t idx);
_assert_(idx >= 0);
locks_[idx].unlock();
}
/** /**
* Get the locks of all slots. * Get the locks of all slots.
*/ */
void lock_all() { void lock_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].lock();
}
}
/** /**
* Release the locks of all slots. * Release the locks of all slots.
*/ */
void unlock_all() { void unlock_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].unlock();
}
}
private: private:
/** The inner devices. */ /** Opaque pointer. */
Mutex locks_[SLOTNUM]; void* opq_;
}; };
/** /**
* Lightweight mutual exclusion device. * Lightweight mutual exclusion device.
*/ */
class SpinLock { class SpinLock {
public: public:
/** /**
* Default constructor. * Default constructor.
*/ */
skipping to change at line 288 skipping to change at line 271
/** Dummy constructor to forbid the use. */ /** Dummy constructor to forbid the use. */
ScopedSpinLock(const ScopedSpinLock&); ScopedSpinLock(const ScopedSpinLock&);
/** Dummy Operator to forbid the use. */ /** Dummy Operator to forbid the use. */
ScopedSpinLock& operator =(const ScopedSpinLock&); ScopedSpinLock& operator =(const ScopedSpinLock&);
/** The inner device. */ /** The inner device. */
SpinLock* spinlock_; SpinLock* spinlock_;
}; };
/** /**
* Slotted spin lock devices. * Slotted spin lock devices.
* @param SLOTNUM the number of slots.
*/ */
template <int32_t SLOTNUM>
class SlottedSpinLock { class SlottedSpinLock {
public: public:
/** /**
* Constructor. * Constructor.
* @param slotnum the number of slots.
*/ */
explicit SlottedSpinLock() : locks_() { explicit SlottedSpinLock(size_t slotnum);
_assert_(true);
}
/** /**
* Destructor. * Destructor.
*/ */
~SlottedSpinLock() { ~SlottedSpinLock();
_assert_(true);
}
/** /**
* Get the lock of a slot. * Get the lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void lock(int32_t idx) { void lock(size_t idx);
_assert_(idx >= 0);
locks_[idx].lock();
}
/** /**
* Release the lock of a slot. * Release the lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void unlock(int32_t idx) { void unlock(size_t idx);
_assert_(idx >= 0);
locks_[idx].unlock();
}
/** /**
* Get the locks of all slots. * Get the locks of all slots.
*/ */
void lock_all() { void lock_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].lock();
}
}
/** /**
* Release the locks of all slots. * Release the locks of all slots.
*/ */
void unlock_all() { void unlock_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].unlock();
}
}
private: private:
/** The inner devices. */ /** Opaque pointer. */
SpinLock locks_[SLOTNUM]; void* opq_;
}; };
/** /**
* Reader-writer locking device. * Reader-writer locking device.
*/ */
class RWLock { class RWLock {
public: public:
/** /**
* Default constructor. * Default constructor.
*/ */
skipping to change at line 424 skipping to change at line 386
/** Dummy constructor to forbid the use. */ /** Dummy constructor to forbid the use. */
ScopedRWLock(const ScopedRWLock&); ScopedRWLock(const ScopedRWLock&);
/** Dummy Operator to forbid the use. */ /** Dummy Operator to forbid the use. */
ScopedRWLock& operator =(const ScopedRWLock&); ScopedRWLock& operator =(const ScopedRWLock&);
/** The inner device. */ /** The inner device. */
RWLock* rwlock_; RWLock* rwlock_;
}; };
/** /**
* Slotted reader-writer lock devices. * Slotted reader-writer lock devices.
* @param SLOTNUM the number of slots.
*/ */
template <int32_t SLOTNUM>
class SlottedRWLock { class SlottedRWLock {
public: public:
/** /**
* Constructor. * Constructor.
* @param slotnum the number of slots.
*/ */
explicit SlottedRWLock() : locks_() { explicit SlottedRWLock(size_t slotnum);
_assert_(true);
}
/** /**
* Destructor. * Destructor.
*/ */
~SlottedRWLock() { ~SlottedRWLock();
_assert_(true);
}
/** /**
* Get the writer lock of a slot. * Get the writer lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void lock_writer(int32_t idx) { void lock_writer(size_t idx);
_assert_(idx >= 0);
locks_[idx].lock_writer();
}
/** /**
* Get the reader lock of a slot. * Get the reader lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void lock_reader(int32_t idx) { void lock_reader(size_t idx);
_assert_(idx >= 0);
locks_[idx].lock_reader();
}
/** /**
* Release the lock of a slot. * Release the lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void unlock(int32_t idx) { void unlock(size_t idx);
_assert_(idx >= 0);
locks_[idx].unlock();
}
/** /**
* Get the writer locks of all slots. * Get the writer locks of all slots.
*/ */
void lock_writer_all() { void lock_writer_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].lock_writer();
}
}
/** /**
* Get the reader locks of all slots. * Get the reader locks of all slots.
*/ */
void lock_reader_all() { void lock_reader_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].lock_reader();
}
}
/** /**
* Release the locks of all slots. * Release the locks of all slots.
*/ */
void unlock_all() { void unlock_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].unlock();
}
}
private: private:
/** The inner devices. */ /** Opaque pointer. */
RWLock locks_[SLOTNUM]; void* opq_;
}; };
/** /**
* Lightweight reader-writer locking device. * Lightweight reader-writer locking device.
*/ */
class SpinRWLock { class SpinRWLock {
public: public:
/** /**
* Default constructor. * Default constructor.
*/ */
skipping to change at line 586 skipping to change at line 519
/** Dummy constructor to forbid the use. */ /** Dummy constructor to forbid the use. */
ScopedSpinRWLock(const ScopedSpinRWLock&); ScopedSpinRWLock(const ScopedSpinRWLock&);
/** Dummy Operator to forbid the use. */ /** Dummy Operator to forbid the use. */
ScopedSpinRWLock& operator =(const ScopedSpinRWLock&); ScopedSpinRWLock& operator =(const ScopedSpinRWLock&);
/** The inner device. */ /** The inner device. */
SpinRWLock* srwlock_; SpinRWLock* srwlock_;
}; };
/** /**
* Slotted lightweight reader-writer lock devices. * Slotted lightweight reader-writer lock devices.
* @param SLOTNUM the number of slots.
*/ */
template <int32_t SLOTNUM>
class SlottedSpinRWLock { class SlottedSpinRWLock {
public: public:
/** /**
* Constructor. * Constructor.
* @param slotnum the number of slots.
*/ */
explicit SlottedSpinRWLock() : locks_() { explicit SlottedSpinRWLock(size_t slotnum);
_assert_(true);
}
/** /**
* Destructor. * Destructor.
*/ */
~SlottedSpinRWLock() { ~SlottedSpinRWLock();
_assert_(true);
}
/** /**
* Get the writer lock of a slot. * Get the writer lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void lock_writer(int32_t idx) { void lock_writer(size_t idx);
_assert_(idx >= 0);
locks_[idx].lock_writer();
}
/** /**
* Get the reader lock of a slot. * Get the reader lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void lock_reader(int32_t idx) { void lock_reader(size_t idx);
_assert_(idx >= 0);
locks_[idx].lock_reader();
}
/** /**
* Release the lock of a slot. * Release the lock of a slot.
* @param idx the index of a slot. * @param idx the index of a slot.
*/ */
void unlock(int32_t idx) { void unlock(size_t idx);
_assert_(idx >= 0);
locks_[idx].unlock();
}
/** /**
* Get the writer locks of all slots. * Get the writer locks of all slots.
*/ */
void lock_writer_all() { void lock_writer_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].lock_writer();
}
}
/** /**
* Get the reader locks of all slots. * Get the reader locks of all slots.
*/ */
void lock_reader_all() { void lock_reader_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].lock_reader();
}
}
/** /**
* Release the locks of all slots. * Release the locks of all slots.
*/ */
void unlock_all() { void unlock_all();
_assert_(true);
for (int32_t i = 0; i < SLOTNUM; i++) {
locks_[i].unlock();
}
}
private: private:
/** The inner devices. */ /** Opaque pointer. */
SpinRWLock locks_[SLOTNUM]; void* opq_;
}; };
/** /**
* Condition variable. * Condition variable.
*/ */
class CondVar { class CondVar {
public: public:
/** /**
* Default constructor. * Default constructor.
*/ */
 End of changes. 45 change blocks. 
140 lines changed or deleted 44 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/