summaryrefslogtreecommitdiff
path: root/plugins/Dbx_kyoto/src/kyotocabinet/kcprotodb.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_kyoto/src/kyotocabinet/kcprotodb.h')
-rw-r--r--plugins/Dbx_kyoto/src/kyotocabinet/kcprotodb.h82
1 files changed, 40 insertions, 42 deletions
diff --git a/plugins/Dbx_kyoto/src/kyotocabinet/kcprotodb.h b/plugins/Dbx_kyoto/src/kyotocabinet/kcprotodb.h
index 5350ced154..7abe493916 100644
--- a/plugins/Dbx_kyoto/src/kyotocabinet/kcprotodb.h
+++ b/plugins/Dbx_kyoto/src/kyotocabinet/kcprotodb.h
@@ -72,7 +72,7 @@ class ProtoDB : public BasicDB {
*/
explicit Cursor(ProtoDB* db) : db_(db), it_(db->recs_.end()) {
_assert_(db);
- ScopedRWLock lock(&db_->mlock_, true);
+ // ScopedRWLock lock(&db_->mlock_, true);
db_->curs_.push_back(this);
}
/**
@@ -81,7 +81,7 @@ class ProtoDB : public BasicDB {
virtual ~Cursor() {
_assert_(true);
if (!db_) return;
- ScopedRWLock lock(&db_->mlock_, true);
+ // ScopedRWLock lock(&db_->mlock_, true);
db_->curs_.remove(this);
}
/**
@@ -96,7 +96,7 @@ class ProtoDB : public BasicDB {
*/
bool accept(Visitor* visitor, bool writable = true, bool step = false) {
_assert_(visitor);
- ScopedRWLock lock(&db_->mlock_, true);
+ // ScopedRWLock lock(&db_->mlock_, true);
if (db_->omode_ == 0) {
db_->set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -150,7 +150,7 @@ class ProtoDB : public BasicDB {
*/
bool jump() {
_assert_(true);
- ScopedRWLock lock(&db_->mlock_, true);
+ // ScopedRWLock lock(&db_->mlock_, true);
if (db_->omode_ == 0) {
db_->set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -170,7 +170,7 @@ class ProtoDB : public BasicDB {
*/
bool jump(const char* kbuf, size_t ksiz) {
_assert_(kbuf && ksiz <= MEMMAXSIZ);
- ScopedRWLock lock(&db_->mlock_, true);
+ // ScopedRWLock lock(&db_->mlock_, true);
if (db_->omode_ == 0) {
db_->set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -197,7 +197,7 @@ class ProtoDB : public BasicDB {
*/
bool jump_back() {
_assert_(true);
- ScopedRWLock lock(&db_->mlock_, true);
+ // ScopedRWLock lock(&db_->mlock_, true);
if (db_->omode_ == 0) {
db_->set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -221,7 +221,7 @@ class ProtoDB : public BasicDB {
*/
bool jump_back(const char* kbuf, size_t ksiz) {
_assert_(kbuf && ksiz <= MEMMAXSIZ);
- ScopedRWLock lock(&db_->mlock_, true);
+ // ScopedRWLock lock(&db_->mlock_, true);
if (db_->omode_ == 0) {
db_->set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -269,7 +269,7 @@ class ProtoDB : public BasicDB {
*/
bool step() {
_assert_(true);
- ScopedRWLock lock(&db_->mlock_, true);
+ // ScopedRWLock lock(&db_->mlock_, true);
if (db_->omode_ == 0) {
db_->set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -291,7 +291,7 @@ class ProtoDB : public BasicDB {
*/
bool step_back() {
_assert_(true);
- ScopedRWLock lock(&db_->mlock_, true);
+ // ScopedRWLock lock(&db_->mlock_, true);
if (db_->omode_ == 0) {
db_->set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -339,7 +339,7 @@ class ProtoDB : public BasicDB {
* Default constructor.
*/
explicit ProtoDB() :
- mlock_(), error_(), logger_(NULL), logkinds_(0), mtrigger_(NULL),
+ error_(), logger_(NULL), logkinds_(0), mtrigger_(NULL),
omode_(0), recs_(), curs_(), path_(""), size_(0), opaque_(),
tran_(false), trlogs_(), trsize_(0) {
_assert_(true);
@@ -376,7 +376,7 @@ class ProtoDB : public BasicDB {
bool accept(const char* kbuf, size_t ksiz, Visitor* visitor, bool writable = true) {
_assert_(kbuf && ksiz <= MEMMAXSIZ && visitor);
if (writable) {
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -429,7 +429,7 @@ class ProtoDB : public BasicDB {
}
}
} else {
- ScopedRWLock lock(&mlock_, false);
+ // ScopedRWLock lock(&mlock_, false);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -469,7 +469,7 @@ class ProtoDB : public BasicDB {
bool accept_bulk(const std::vector<std::string>& keys, Visitor* visitor,
bool writable = true) {
_assert_(visitor);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -542,7 +542,7 @@ class ProtoDB : public BasicDB {
*/
bool iterate(Visitor *visitor, bool writable = true, ProgressChecker* checker = NULL) {
_assert_(visitor);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -602,7 +602,7 @@ class ProtoDB : public BasicDB {
*/
bool scan_parallel(Visitor *visitor, size_t thnum, ProgressChecker* checker = NULL) {
_assert_(visitor && thnum <= MEMMAXSIZ);
- ScopedRWLock lock(&mlock_, false);
+ // ScopedRWLock lock(&mlock_, false);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -749,7 +749,7 @@ class ProtoDB : public BasicDB {
*/
bool open(const std::string& path, uint32_t mode = OWRITER | OCREATE) {
_assert_(true);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ != 0) {
set_error(_KCCODELINE_, Error::INVALID, "already opened");
return false;
@@ -767,7 +767,7 @@ class ProtoDB : public BasicDB {
*/
bool close() {
_assert_(true);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -804,7 +804,7 @@ class ProtoDB : public BasicDB {
bool synchronize(bool hard = false, FileProcessor* proc = NULL,
ProgressChecker* checker = NULL) {
_assert_(true);
- ScopedRWLock lock(&mlock_, false);
+ // ScopedRWLock lock(&mlock_, false);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -839,7 +839,7 @@ class ProtoDB : public BasicDB {
*/
bool occupy(bool writable = true, FileProcessor* proc = NULL) {
_assert_(true);
- ScopedRWLock lock(&mlock_, writable);
+ // ScopedRWLock lock(&mlock_, writable);
bool err = false;
if (proc && !proc->process(path_, recs_.size(), size_)) {
set_error(_KCCODELINE_, Error::LOGIC, "processing failed");
@@ -858,19 +858,19 @@ class ProtoDB : public BasicDB {
_assert_(true);
uint32_t wcnt = 0;
while (true) {
- mlock_.lock_writer();
+ // mlock_.lock_writer();
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
- mlock_.unlock();
+ // mlock_.unlock();
return false;
}
if (!(omode_ & OWRITER)) {
set_error(_KCCODELINE_, Error::NOPERM, "permission denied");
- mlock_.unlock();
+ // mlock_.unlock();
return false;
}
if (!tran_) break;
- mlock_.unlock();
+ // mlock_.unlock();
if (wcnt >= LOCKBUSYLOOP) {
Thread::chill();
} else {
@@ -881,7 +881,7 @@ class ProtoDB : public BasicDB {
tran_ = true;
trsize_ = size_;
trigger_meta(MetaTrigger::BEGINTRAN, "begin_transaction");
- mlock_.unlock();
+ // mlock_.unlock();
return true;
}
/**
@@ -892,26 +892,26 @@ class ProtoDB : public BasicDB {
*/
bool begin_transaction_try(bool hard = false) {
_assert_(true);
- mlock_.lock_writer();
+ // mlock_.lock_writer();
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
- mlock_.unlock();
+ // mlock_.unlock();
return false;
}
if (!(omode_ & OWRITER)) {
set_error(_KCCODELINE_, Error::NOPERM, "permission denied");
- mlock_.unlock();
+ // mlock_.unlock();
return false;
}
if (tran_) {
set_error(_KCCODELINE_, Error::LOGIC, "competition avoided");
- mlock_.unlock();
+ // mlock_.unlock();
return false;
}
tran_ = true;
trsize_ = size_;
trigger_meta(MetaTrigger::BEGINTRAN, "begin_transaction_try");
- mlock_.unlock();
+ // mlock_.unlock();
return true;
}
/**
@@ -921,7 +921,7 @@ class ProtoDB : public BasicDB {
*/
bool end_transaction(bool commit = true) {
_assert_(true);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -964,7 +964,7 @@ class ProtoDB : public BasicDB {
*/
bool clear() {
_assert_(true);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -989,7 +989,7 @@ class ProtoDB : public BasicDB {
*/
int64_t count() {
_assert_(true);
- ScopedRWLock lock(&mlock_, false);
+ // ScopedRWLock lock(&mlock_, false);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return -1;
@@ -1002,7 +1002,7 @@ class ProtoDB : public BasicDB {
*/
int64_t size() {
_assert_(true);
- ScopedRWLock lock(&mlock_, false);
+ // ScopedRWLock lock(&mlock_, false);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return -1;
@@ -1015,7 +1015,7 @@ class ProtoDB : public BasicDB {
*/
std::string path() {
_assert_(true);
- ScopedRWLock lock(&mlock_, false);
+ // ScopedRWLock lock(&mlock_, false);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return "";
@@ -1029,7 +1029,7 @@ class ProtoDB : public BasicDB {
*/
bool status(std::map<std::string, std::string>* strmap) {
_assert_(strmap);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -1065,7 +1065,7 @@ class ProtoDB : public BasicDB {
void log(const char* file, int32_t line, const char* func, Logger::Kind kind,
const char* message) {
_assert_(file && line > 0 && func && message);
- ScopedRWLock lock(&mlock_, false);
+ // ScopedRWLock lock(&mlock_, false);
if (!logger_) return;
logger_->log(file, line, func, kind, message);
}
@@ -1079,7 +1079,7 @@ class ProtoDB : public BasicDB {
*/
bool tune_logger(Logger* logger, uint32_t kinds = Logger::WARN | Logger::ERROR) {
_assert_(logger);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ != 0) {
set_error(_KCCODELINE_, Error::INVALID, "already opened");
return false;
@@ -1095,7 +1095,7 @@ class ProtoDB : public BasicDB {
*/
bool tune_meta_trigger(MetaTrigger* trigger) {
_assert_(trigger);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ != 0) {
set_error(_KCCODELINE_, Error::INVALID, "already opened");
return false;
@@ -1109,7 +1109,7 @@ class ProtoDB : public BasicDB {
*/
char* opaque() {
_assert_(true);
- ScopedRWLock lock(&mlock_, false);
+ // ScopedRWLock lock(&mlock_, false);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return NULL;
@@ -1122,7 +1122,7 @@ class ProtoDB : public BasicDB {
*/
bool synchronize_opaque() {
_assert_(true);
- ScopedRWLock lock(&mlock_, true);
+ // ScopedRWLock lock(&mlock_, true);
if (omode_ == 0) {
set_error(_KCCODELINE_, Error::INVALID, "not opened");
return false;
@@ -1251,8 +1251,6 @@ class ProtoDB : public BasicDB {
ProtoDB(const ProtoDB&);
/** Dummy Operator to forbid the use. */
ProtoDB& operator =(const ProtoDB&);
- /** The method lock. */
- RWLock mlock_;
/** The last happened error. */
TSD<Error> error_;
/** The internal logger. */