| kccachedb.h | | kccachedb.h | |
| | | | |
| skipping to change at line 664 | | skipping to change at line 664 | |
| trigger_meta(MetaTrigger::CLOSE, "close"); | | trigger_meta(MetaTrigger::CLOSE, "close"); | |
| return true; | | return true; | |
| } | | } | |
| /** | | /** | |
| * Synchronize updated contents with the file and the device. | | * Synchronize updated contents with the file and the device. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | | * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | |
| * @param checker a progress checker object. If it is NULL, no checking
is performed. | | * @param checker a progress checker object. If it is NULL, no checking
is performed. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
|
| | | * @note The operation of the postprocessor is performed atomically and o | |
| | | ther threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| */ | | */ | |
| bool synchronize(bool hard = false, FileProcessor* proc = NULL, | | bool synchronize(bool hard = false, FileProcessor* proc = NULL, | |
| ProgressChecker* checker = NULL) { | | ProgressChecker* checker = NULL) { | |
| _assert_(true); | | _assert_(true); | |
| ScopedSpinRWLock lock(&mlock_, false); | | ScopedSpinRWLock lock(&mlock_, false); | |
| if (omode_ == 0) { | | if (omode_ == 0) { | |
| set_error(_KCCODELINE_, Error::INVALID, "not opened"); | | set_error(_KCCODELINE_, Error::INVALID, "not opened"); | |
| return false; | | return false; | |
| } | | } | |
| bool err = false; | | bool err = false; | |
| | | | |
| skipping to change at line 693 | | skipping to change at line 696 | |
| } | | } | |
| if (!proc->process(path_, count_impl(), size_impl())) { | | if (!proc->process(path_, count_impl(), size_impl())) { | |
| set_error(_KCCODELINE_, Error::LOGIC, "postprocessing failed"); | | set_error(_KCCODELINE_, Error::LOGIC, "postprocessing failed"); | |
| err = true; | | err = true; | |
| } | | } | |
| } | | } | |
| trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | | trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
|
| | | * Occupy database by locking and do something meanwhile. | |
| | | * @param writable true to use writer lock, or false to use reader lock. | |
| | | * @param proc a processor object. If it is NULL, no processing is perfo | |
| | | rmed. | |
| | | * @return true on success, or false on failure. | |
| | | * @note The operation of the processor is performed atomically and other | |
| | | threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| | | */ | |
| | | bool occupy(bool writable = true, FileProcessor* proc = NULL) { | |
| | | _assert_(true); | |
| | | ScopedSpinRWLock lock(&mlock_, writable); | |
| | | bool err = false; | |
| | | if (proc && !proc->process(path_, count_impl(), size_impl())) { | |
| | | set_error(_KCCODELINE_, Error::LOGIC, "processing failed"); | |
| | | err = true; | |
| | | } | |
| | | trigger_meta(MetaTrigger::OCCUPY, "occupy"); | |
| | | return !err; | |
| | | } | |
| | | /** | |
| * Begin transaction. | | * Begin transaction. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| bool begin_transaction(bool hard = false) { | | bool begin_transaction(bool hard = false) { | |
| _assert_(true); | | _assert_(true); | |
| uint32_t wcnt = 0; | | uint32_t wcnt = 0; | |
| while (true) { | | while (true) { | |
| mlock_.lock_writer(); | | mlock_.lock_writer(); | |
| | | | |
| skipping to change at line 1417 | | skipping to change at line 1440 | |
| class Remover : public Visitor { | | class Remover : public Visitor { | |
| private: | | private: | |
| /** visit a record */ | | /** visit a record */ | |
| const char* visit_full(const char* kbuf, size_t ksiz, | | const char* visit_full(const char* kbuf, size_t ksiz, | |
| const char* vbuf, size_t vsiz, size_t* sp) { | | const char* vbuf, size_t vsiz, size_t* sp) { | |
| _assert_(kbuf && ksiz <= MEMMAXSIZ && vbuf && vsiz <= MEMMAXSIZ && sp
); | | _assert_(kbuf && ksiz <= MEMMAXSIZ && vbuf && vsiz <= MEMMAXSIZ && sp
); | |
| return REMOVE; | | return REMOVE; | |
| } | | } | |
| }; | | }; | |
| /** | | /** | |
|
| * Scoped visiotor. | | * Scoped visitor. | |
| */ | | */ | |
| class ScopedVisitor { | | class ScopedVisitor { | |
| public: | | public: | |
| /** constructor */ | | /** constructor */ | |
|
| ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | | explicit ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | |
| _assert_(visitor); | | _assert_(visitor); | |
| visitor_->visit_before(); | | visitor_->visit_before(); | |
| } | | } | |
| /** destructor */ | | /** destructor */ | |
| ~ScopedVisitor() { | | ~ScopedVisitor() { | |
| _assert_(true); | | _assert_(true); | |
| visitor_->visit_after(); | | visitor_->visit_after(); | |
| } | | } | |
| private: | | private: | |
| Visitor* visitor_; ///< visitor | | Visitor* visitor_; ///< visitor | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 30 lines changed or added | |
|
| kcdb.h | | kcdb.h | |
| | | | |
| skipping to change at line 970 | | skipping to change at line 970 | |
| public: | | public: | |
| /** | | /** | |
| * Destructor. | | * Destructor. | |
| */ | | */ | |
| virtual ~FileProcessor() { | | virtual ~FileProcessor() { | |
| _assert_(true); | | _assert_(true); | |
| } | | } | |
| /** | | /** | |
| * Process the database file. | | * Process the database file. | |
| * @param path the path of the database file. | | * @param path the path of the database file. | |
|
| * @param count the number of records. | | * @param count the number of records. A negative value means omission | |
| * @param size the size of the available region. | | . | |
| | | * @param size the size of the available region. A negative value mean | |
| | | s omission. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| virtual bool process(const std::string& path, int64_t count, int64_t si
ze) = 0; | | virtual bool process(const std::string& path, int64_t count, int64_t si
ze) = 0; | |
| }; | | }; | |
| /** | | /** | |
| * Interface to log internal information and errors. | | * Interface to log internal information and errors. | |
| */ | | */ | |
| class Logger { | | class Logger { | |
| public: | | public: | |
| /** | | /** | |
| | | | |
| skipping to change at line 1022 | | skipping to change at line 1022 | |
| public: | | public: | |
| /** | | /** | |
| * Event kinds. | | * Event kinds. | |
| */ | | */ | |
| enum Kind { | | enum Kind { | |
| OPEN, ///< opening | | OPEN, ///< opening | |
| CLOSE, ///< closing | | CLOSE, ///< closing | |
| CLEAR, ///< clearing | | CLEAR, ///< clearing | |
| ITERATE, ///< iteration | | ITERATE, ///< iteration | |
| SYNCHRONIZE, ///< synchronization | | SYNCHRONIZE, ///< synchronization | |
|
| | | OCCUPY, ///< occupation | |
| BEGINTRAN, ///< beginning transaction | | BEGINTRAN, ///< beginning transaction | |
| COMMITTRAN, ///< committing transaction | | COMMITTRAN, ///< committing transaction | |
| ABORTTRAN, ///< aborting transaction | | ABORTTRAN, ///< aborting transaction | |
| MISC = 15 ///< miscellaneous operation | | MISC = 15 ///< miscellaneous operation | |
| }; | | }; | |
| /** | | /** | |
| * Destructor. | | * Destructor. | |
| */ | | */ | |
| virtual ~MetaTrigger() { | | virtual ~MetaTrigger() { | |
| _assert_(true); | | _assert_(true); | |
| } | | } | |
| /** | | /** | |
| * Trigger a meta database operation. | | * Trigger a meta database operation. | |
| * @param kind the kind of the event. MetaTrigger::OPEN for opening, M
etaTrigger::CLOSE for | | * @param kind the kind of the event. MetaTrigger::OPEN for opening, M
etaTrigger::CLOSE for | |
| * closing, MetaTrigger::CLEAR for clearing, MetaTrigger::ITERATE for i
teration, | | * closing, MetaTrigger::CLEAR for clearing, MetaTrigger::ITERATE for i
teration, | |
|
| * MetaTrigger::SYNCHRONIZE for synchronization, MetaTrigger::BEGINTRAN | | * MetaTrigger::SYNCHRONIZE for synchronization, MetaTrigger::OCCUPY fo | |
| for beginning | | r occupation, | |
| * transaction, MetaTrigger::COMMITTRAN for committing transaction, Met | | * MetaTrigger::BEGINTRAN for beginning transaction, MetaTrigger::COMMI | |
| aTrigger::ABORTTRAN | | TTRAN for committing | |
| * for aborting transaction, and MetaTrigger::MISC for miscellaneous op | | * transaction, MetaTrigger::ABORTTRAN for aborting transaction, and Me | |
| erations. | | taTrigger::MISC for | |
| | | * miscellaneous operations. | |
| * @param message the supplement message. | | * @param message the supplement message. | |
| */ | | */ | |
| virtual void trigger(Kind kind, const char* message) = 0; | | virtual void trigger(Kind kind, const char* message) = 0; | |
| }; | | }; | |
| /** | | /** | |
| * Open modes. | | * Open modes. | |
| */ | | */ | |
| enum OpenMode { | | enum OpenMode { | |
| OREADER = 1 << 0, ///< open as a reader | | OREADER = 1 << 0, ///< open as a reader | |
| OWRITER = 1 << 1, ///< open as a writer | | OWRITER = 1 << 1, ///< open as a writer | |
| | | | |
| skipping to change at line 1134 | | skipping to change at line 1136 | |
| */ | | */ | |
| virtual bool iterate(Visitor *visitor, bool writable = true, | | virtual bool iterate(Visitor *visitor, bool writable = true, | |
| ProgressChecker* checker = NULL) = 0; | | ProgressChecker* checker = NULL) = 0; | |
| /** | | /** | |
| * Synchronize updated contents with the file and the device. | | * Synchronize updated contents with the file and the device. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | | * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | |
| * @param checker a progress checker object. If it is NULL, no checking
is performed. | | * @param checker a progress checker object. If it is NULL, no checking
is performed. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
|
| | | * @note The operation of the postprocessor is performed atomically and o | |
| | | ther threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| */ | | */ | |
| virtual bool synchronize(bool hard = false, FileProcessor* proc = NULL, | | virtual bool synchronize(bool hard = false, FileProcessor* proc = NULL, | |
| ProgressChecker* checker = NULL) = 0; | | ProgressChecker* checker = NULL) = 0; | |
| /** | | /** | |
|
| | | * Occupy database by locking and do something meanwhile. | |
| | | * @param writable true to use writer lock, or false to use reader lock. | |
| | | * @param proc a processor object. If it is NULL, no processing is perfo | |
| | | rmed. | |
| | | * @return true on success, or false on failure. | |
| | | * @note The operation of the processor is performed atomically and other | |
| | | threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| | | */ | |
| | | virtual bool occupy(bool writable = true, FileProcessor* proc = NULL) = 0 | |
| | | ; | |
| | | /** | |
| * Create a copy of the database file. | | * Create a copy of the database file. | |
| * @param dest the path of the destination file. | | * @param dest the path of the destination file. | |
| * @param checker a progress checker object. If it is NULL, no checking
is performed. | | * @param checker a progress checker object. If it is NULL, no checking
is performed. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| bool copy(const std::string& dest, ProgressChecker* checker = NULL) { | | bool copy(const std::string& dest, ProgressChecker* checker = NULL) { | |
| _assert_(true); | | _assert_(true); | |
| class FileProcessorImpl : public FileProcessor { | | class FileProcessorImpl : public FileProcessor { | |
| public: | | public: | |
| explicit FileProcessorImpl(const std::string& dest, ProgressChecker*
checker, | | explicit FileProcessorImpl(const std::string& dest, ProgressChecker*
checker, | |
| | | | |
End of changes. 5 change blocks. |
| 8 lines changed or deleted | | 31 lines changed or added | |
|
| kcdirdb.h | | kcdirdb.h | |
| | | | |
| skipping to change at line 807 | | skipping to change at line 807 | |
| trigger_meta(MetaTrigger::CLOSE, "close"); | | trigger_meta(MetaTrigger::CLOSE, "close"); | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
| * Synchronize updated contents with the file and the device. | | * Synchronize updated contents with the file and the device. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | | * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | |
| * @param checker a progress checker object. If it is NULL, no checking
is performed. | | * @param checker a progress checker object. If it is NULL, no checking
is performed. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
|
| | | * @note The operation of the postprocessor is performed atomically and o | |
| | | ther threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| */ | | */ | |
| bool synchronize(bool hard = false, FileProcessor* proc = NULL, | | bool synchronize(bool hard = false, FileProcessor* proc = NULL, | |
| ProgressChecker* checker = NULL) { | | ProgressChecker* checker = NULL) { | |
| _assert_(true); | | _assert_(true); | |
| ScopedSpinRWLock lock(&mlock_, false); | | ScopedSpinRWLock lock(&mlock_, false); | |
| if (omode_ == 0) { | | if (omode_ == 0) { | |
| set_error(_KCCODELINE_, Error::INVALID, "not opened"); | | set_error(_KCCODELINE_, Error::INVALID, "not opened"); | |
| return false; | | return false; | |
| } | | } | |
| rlock_.lock_reader_all(); | | rlock_.lock_reader_all(); | |
| bool err = false; | | bool err = false; | |
| if (!synchronize_impl(hard, proc, checker)) err = true; | | if (!synchronize_impl(hard, proc, checker)) err = true; | |
| trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | | trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | |
| rlock_.unlock_all(); | | rlock_.unlock_all(); | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
|
| | | * Occupy database by locking and do something meanwhile. | |
| | | * @param writable true to use writer lock, or false to use reader lock. | |
| | | * @param proc a processor object. If it is NULL, no processing is perfo | |
| | | rmed. | |
| | | * @return true on success, or false on failure. | |
| | | * @note The operation of the processor is performed atomically and other | |
| | | threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| | | */ | |
| | | bool occupy(bool writable = true, FileProcessor* proc = NULL) { | |
| | | _assert_(true); | |
| | | ScopedSpinRWLock lock(&mlock_, writable); | |
| | | bool err = false; | |
| | | if (proc && !proc->process(path_, count_, size_impl())) { | |
| | | set_error(_KCCODELINE_, Error::LOGIC, "processing failed"); | |
| | | err = true; | |
| | | } | |
| | | trigger_meta(MetaTrigger::OCCUPY, "occupy"); | |
| | | return !err; | |
| | | } | |
| | | /** | |
| * Begin transaction. | | * Begin transaction. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| bool begin_transaction(bool hard = false) { | | bool begin_transaction(bool hard = false) { | |
| _assert_(true); | | _assert_(true); | |
| uint32_t wcnt = 0; | | uint32_t wcnt = 0; | |
| while (true) { | | while (true) { | |
| mlock_.lock_writer(); | | mlock_.lock_writer(); | |
| | | | |
| skipping to change at line 1462 | | skipping to change at line 1485 | |
| */ | | */ | |
| struct Record { | | struct Record { | |
| char* rbuf; ///< record buffer | | char* rbuf; ///< record buffer | |
| size_t rsiz; ///< record size | | size_t rsiz; ///< record size | |
| const char* kbuf; ///< key buffer | | const char* kbuf; ///< key buffer | |
| size_t ksiz; ///< key size | | size_t ksiz; ///< key size | |
| const char* vbuf; ///< value buffer | | const char* vbuf; ///< value buffer | |
| size_t vsiz; ///< value size | | size_t vsiz; ///< value size | |
| }; | | }; | |
| /** | | /** | |
|
| * Scoped visiotor. | | * Scoped visitor. | |
| */ | | */ | |
| class ScopedVisitor { | | class ScopedVisitor { | |
| public: | | public: | |
| /** constructor */ | | /** constructor */ | |
|
| ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | | explicit ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | |
| _assert_(visitor); | | _assert_(visitor); | |
| visitor_->visit_before(); | | visitor_->visit_before(); | |
| } | | } | |
| /** destructor */ | | /** destructor */ | |
| ~ScopedVisitor() { | | ~ScopedVisitor() { | |
| _assert_(true); | | _assert_(true); | |
| visitor_->visit_after(); | | visitor_->visit_after(); | |
| } | | } | |
| private: | | private: | |
| Visitor* visitor_; ///< visitor | | Visitor* visitor_; ///< visitor | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 30 lines changed or added | |
|
| kchashdb.h | | kchashdb.h | |
| | | | |
| skipping to change at line 932 | | skipping to change at line 932 | |
| trigger_meta(MetaTrigger::CLOSE, "close"); | | trigger_meta(MetaTrigger::CLOSE, "close"); | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
| * Synchronize updated contents with the file and the device. | | * Synchronize updated contents with the file and the device. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | | * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | |
| * @param checker a progress checker object. If it is NULL, no checking
is performed. | | * @param checker a progress checker object. If it is NULL, no checking
is performed. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
|
| | | * @note The operation of the postprocessor is performed atomically and o | |
| | | ther threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| */ | | */ | |
| bool synchronize(bool hard = false, FileProcessor* proc = NULL, | | bool synchronize(bool hard = false, FileProcessor* proc = NULL, | |
| ProgressChecker* checker = NULL) { | | ProgressChecker* checker = NULL) { | |
| _assert_(true); | | _assert_(true); | |
| ScopedSpinRWLock lock(&mlock_, false); | | ScopedSpinRWLock lock(&mlock_, false); | |
| if (omode_ == 0) { | | if (omode_ == 0) { | |
| set_error(_KCCODELINE_, Error::INVALID, "not opened"); | | set_error(_KCCODELINE_, Error::INVALID, "not opened"); | |
| return false; | | return false; | |
| } | | } | |
| rlock_.lock_reader_all(); | | rlock_.lock_reader_all(); | |
| bool err = false; | | bool err = false; | |
| if (!synchronize_impl(hard, proc, checker)) err = true; | | if (!synchronize_impl(hard, proc, checker)) err = true; | |
| trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | | trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | |
| rlock_.unlock_all(); | | rlock_.unlock_all(); | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
|
| | | * Occupy database by locking and do something meanwhile. | |
| | | * @param writable true to use writer lock, or false to use reader lock. | |
| | | * @param proc a processor object. If it is NULL, no processing is perfo | |
| | | rmed. | |
| | | * @return true on success, or false on failure. | |
| | | * @note The operation of the processor is performed atomically and other | |
| | | threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| | | */ | |
| | | bool occupy(bool writable = true, FileProcessor* proc = NULL) { | |
| | | _assert_(true); | |
| | | ScopedSpinRWLock lock(&mlock_, writable); | |
| | | bool err = false; | |
| | | if (proc && !proc->process(path_, count_, lsiz_)) { | |
| | | set_error(_KCCODELINE_, Error::LOGIC, "processing failed"); | |
| | | err = true; | |
| | | } | |
| | | trigger_meta(MetaTrigger::OCCUPY, "occupy"); | |
| | | return !err; | |
| | | } | |
| | | /** | |
| * Begin transaction. | | * Begin transaction. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| bool begin_transaction(bool hard = false) { | | bool begin_transaction(bool hard = false) { | |
| _assert_(true); | | _assert_(true); | |
| uint32_t wcnt = 0; | | uint32_t wcnt = 0; | |
| while (true) { | | while (true) { | |
| mlock_.lock_writer(); | | mlock_.lock_writer(); | |
| | | | |
| skipping to change at line 1737 | | skipping to change at line 1760 | |
| const char* visit_full(const char* kbuf, size_t ksiz, | | const char* visit_full(const char* kbuf, size_t ksiz, | |
| const char* vbuf, size_t vsiz, size_t* sp) { | | const char* vbuf, size_t vsiz, size_t* sp) { | |
| _assert_(kbuf && ksiz <= MEMMAXSIZ && vbuf && vsiz <= MEMMAXSIZ && sp
); | | _assert_(kbuf && ksiz <= MEMMAXSIZ && vbuf && vsiz <= MEMMAXSIZ && sp
); | |
| *sp = vsiz_; | | *sp = vsiz_; | |
| return vbuf_; | | return vbuf_; | |
| } | | } | |
| const char* vbuf_; | | const char* vbuf_; | |
| size_t vsiz_; | | size_t vsiz_; | |
| }; | | }; | |
| /** | | /** | |
|
| * Scoped visiotor. | | * Scoped visitor. | |
| */ | | */ | |
| class ScopedVisitor { | | class ScopedVisitor { | |
| public: | | public: | |
| /** constructor */ | | /** constructor */ | |
|
| ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | | explicit ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | |
| _assert_(visitor); | | _assert_(visitor); | |
| visitor_->visit_before(); | | visitor_->visit_before(); | |
| } | | } | |
| /** destructor */ | | /** destructor */ | |
| ~ScopedVisitor() { | | ~ScopedVisitor() { | |
| _assert_(true); | | _assert_(true); | |
| visitor_->visit_after(); | | visitor_->visit_after(); | |
| } | | } | |
| private: | | private: | |
| Visitor* visitor_; ///< visitor | | Visitor* visitor_; ///< visitor | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 30 lines changed or added | |
|
| kclangc.h | | kclangc.h | |
| | | | |
| skipping to change at line 559 | | skipping to change at line 559 | |
| | | | |
| /** | | /** | |
| * Synchronize updated contents with the file and the device. | | * Synchronize updated contents with the file and the device. | |
| * @param db a database object. | | * @param db a database object. | |
| * @param hard true for physical synchronization with the device, or false
for logical | | * @param hard true for physical synchronization with the device, or false
for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @param proc a postprocessor call back function. If it is NULL, no postp
rocessing is | | * @param proc a postprocessor call back function. If it is NULL, no postp
rocessing is | |
| * performed. | | * performed. | |
| * @param opq an opaque pointer to be given to the call back function. | | * @param opq an opaque pointer to be given to the call back function. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
|
| | | * @note The operation of the postprocessor is performed atomically and oth | |
| | | er threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database o | |
| | | peration must not | |
| | | * be performed in this function. | |
| */ | | */ | |
| int32_t kcdbsync(KCDB* db, int32_t hard, KCFILEPROC proc, void* opq); | | int32_t kcdbsync(KCDB* db, int32_t hard, KCFILEPROC proc, void* opq); | |
| | | | |
| /** | | /** | |
|
| | | * Occupy database by locking and do something meanwhile. | |
| | | * @param db a database object. | |
| | | * @param writable true to use writer lock, or false to use reader lock. | |
| | | * @param proc a processor object. If it is NULL, no processing is perform | |
| | | ed. | |
| | | * @param opq an opaque pointer to be given to the call back function. | |
| | | * @return true on success, or false on failure. | |
| | | * @note The operation of the processor is performed atomically and other t | |
| | | hreads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database o | |
| | | peration must not | |
| | | * be performed in this function. | |
| | | */ | |
| | | int32_t kcdboccupy(KCDB* db, int32_t writable, KCFILEPROC proc, void* opq); | |
| | | | |
| | | /** | |
| * Create a copy of the database file. | | * Create a copy of the database file. | |
| * @param db a database object. | | * @param db a database object. | |
| * @param dest the path of the destination file. | | * @param dest the path of the destination file. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| int32_t kcdbcopy(KCDB* db, const char* dest); | | int32_t kcdbcopy(KCDB* db, const char* dest); | |
| | | | |
| /** | | /** | |
| * Begin transaction. | | * Begin transaction. | |
| * @param db a database object. | | * @param db a database object. | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 21 lines changed or added | |
|
| kcplantdb.h | | kcplantdb.h | |
| | | | |
| skipping to change at line 1447 | | skipping to change at line 1447 | |
| trigger_meta(MetaTrigger::CLOSE, "close"); | | trigger_meta(MetaTrigger::CLOSE, "close"); | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
| * Synchronize updated contents with the file and the device. | | * Synchronize updated contents with the file and the device. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | | * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | |
| * @param checker a progress checker object. If it is NULL, no checking
is performed. | | * @param checker a progress checker object. If it is NULL, no checking
is performed. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
|
| | | * @note The operation of the postprocessor is performed atomically and o | |
| | | ther threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| */ | | */ | |
| bool synchronize(bool hard = false, FileProcessor* proc = NULL, | | bool synchronize(bool hard = false, FileProcessor* proc = NULL, | |
| ProgressChecker* checker = NULL) { | | ProgressChecker* checker = NULL) { | |
| _assert_(true); | | _assert_(true); | |
| mlock_.lock_reader(); | | mlock_.lock_reader(); | |
| if (omode_ == 0) { | | if (omode_ == 0) { | |
| set_error(_KCCODELINE_, Error::INVALID, "not opened"); | | set_error(_KCCODELINE_, Error::INVALID, "not opened"); | |
| mlock_.unlock(); | | mlock_.unlock(); | |
| return false; | | return false; | |
| } | | } | |
| | | | |
| skipping to change at line 1511 | | skipping to change at line 1514 | |
| } | | } | |
| FileProcessor* proc_; | | FileProcessor* proc_; | |
| int64_t count_; | | int64_t count_; | |
| } wrapper(proc, count_); | | } wrapper(proc, count_); | |
| if (!db_.synchronize(hard, &wrapper, checker)) err = true; | | if (!db_.synchronize(hard, &wrapper, checker)) err = true; | |
| trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | | trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | |
| mlock_.unlock(); | | mlock_.unlock(); | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
|
| | | * Occupy database by locking and do something meanwhile. | |
| | | * @param writable true to use writer lock, or false to use reader lock. | |
| | | * @param proc a processor object. If it is NULL, no processing is perfo | |
| | | rmed. | |
| | | * @return true on success, or false on failure. | |
| | | * @note The operation of the processor is performed atomically and other | |
| | | threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| | | */ | |
| | | bool occupy(bool writable = true, FileProcessor* proc = NULL) { | |
| | | _assert_(true); | |
| | | ScopedSpinRWLock lock(&mlock_, writable); | |
| | | bool err = false; | |
| | | if (proc && !proc->process(db_.path(), count_, db_.size())) { | |
| | | set_error(_KCCODELINE_, Error::LOGIC, "processing failed"); | |
| | | err = true; | |
| | | } | |
| | | trigger_meta(MetaTrigger::OCCUPY, "occupy"); | |
| | | return !err; | |
| | | } | |
| | | /** | |
| * Begin transaction. | | * Begin transaction. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| bool begin_transaction(bool hard = false) { | | bool begin_transaction(bool hard = false) { | |
| _assert_(true); | | _assert_(true); | |
| uint32_t wcnt = 0; | | uint32_t wcnt = 0; | |
| while (true) { | | while (true) { | |
| mlock_.lock_writer(); | | mlock_.lock_writer(); | |
| | | | |
| skipping to change at line 2147 | | skipping to change at line 2170 | |
| LeafCache* warm; ///< warm cache | | LeafCache* warm; ///< warm cache | |
| }; | | }; | |
| /** | | /** | |
| * Slot cache of inner nodes. | | * Slot cache of inner nodes. | |
| */ | | */ | |
| struct InnerSlot { | | struct InnerSlot { | |
| SpinLock lock; ///< lock | | SpinLock lock; ///< lock | |
| InnerCache* warm; ///< warm cache | | InnerCache* warm; ///< warm cache | |
| }; | | }; | |
| /** | | /** | |
|
| * Scoped visiotor. | | * Scoped visitor. | |
| */ | | */ | |
| class ScopedVisitor { | | class ScopedVisitor { | |
| public: | | public: | |
| /** constructor */ | | /** constructor */ | |
|
| ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | | explicit ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | |
| _assert_(visitor); | | _assert_(visitor); | |
| visitor_->visit_before(); | | visitor_->visit_before(); | |
| } | | } | |
| /** destructor */ | | /** destructor */ | |
| ~ScopedVisitor() { | | ~ScopedVisitor() { | |
| _assert_(true); | | _assert_(true); | |
| visitor_->visit_after(); | | visitor_->visit_after(); | |
| } | | } | |
| private: | | private: | |
| Visitor* visitor_; ///< visitor | | Visitor* visitor_; ///< visitor | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 30 lines changed or added | |
|
| kcpolydb.h | | kcpolydb.h | |
| | | | |
| skipping to change at line 918 | | skipping to change at line 918 | |
| zcomp_ = NULL; | | zcomp_ = NULL; | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
| * Synchronize updated contents with the file and the device. | | * Synchronize updated contents with the file and the device. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | | * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | |
| * @param checker a progress checker object. If it is NULL, no checking
is performed. | | * @param checker a progress checker object. If it is NULL, no checking
is performed. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
|
| | | * @note The operation of the postprocessor is performed atomically and o | |
| | | ther threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| */ | | */ | |
| bool synchronize(bool hard = false, FileProcessor* proc = NULL, | | bool synchronize(bool hard = false, FileProcessor* proc = NULL, | |
| ProgressChecker* checker = NULL) { | | ProgressChecker* checker = NULL) { | |
| _assert_(true); | | _assert_(true); | |
| if (type_ == TYPEVOID) { | | if (type_ == TYPEVOID) { | |
| set_error(_KCCODELINE_, Error::INVALID, "not opened"); | | set_error(_KCCODELINE_, Error::INVALID, "not opened"); | |
| return false; | | return false; | |
| } | | } | |
| return db_->synchronize(hard, proc, checker); | | return db_->synchronize(hard, proc, checker); | |
| } | | } | |
| /** | | /** | |
|
| | | * Occupy database by locking and do something meanwhile. | |
| | | * @param writable true to use writer lock, or false to use reader lock. | |
| | | * @param proc a processor object. If it is NULL, no processing is perfo | |
| | | rmed. | |
| | | * @return true on success, or false on failure. | |
| | | * @note The operation of the processor is performed atomically and other | |
| | | threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| | | */ | |
| | | bool occupy(bool writable = true, FileProcessor* proc = NULL) { | |
| | | _assert_(true); | |
| | | if (type_ == TYPEVOID) { | |
| | | set_error(_KCCODELINE_, Error::INVALID, "not opened"); | |
| | | return false; | |
| | | } | |
| | | return db_->occupy(writable, proc); | |
| | | } | |
| | | /** | |
| * Begin transaction. | | * Begin transaction. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| bool begin_transaction(bool hard = false) { | | bool begin_transaction(bool hard = false) { | |
| _assert_(true); | | _assert_(true); | |
| if (type_ == TYPEVOID) { | | if (type_ == TYPEVOID) { | |
| set_error(_KCCODELINE_, Error::INVALID, "not opened"); | | set_error(_KCCODELINE_, Error::INVALID, "not opened"); | |
| return false; | | return false; | |
| | | | |
| skipping to change at line 1392 | | skipping to change at line 1412 | |
| /** print a meta operation */ | | /** print a meta operation */ | |
| void trigger(Kind kind, const char* message) { | | void trigger(Kind kind, const char* message) { | |
| _assert_(message); | | _assert_(message); | |
| const char* kstr = "unknown"; | | const char* kstr = "unknown"; | |
| switch (kind) { | | switch (kind) { | |
| case MetaTrigger::OPEN: kstr = "OPEN"; break; | | case MetaTrigger::OPEN: kstr = "OPEN"; break; | |
| case MetaTrigger::CLOSE: kstr = "CLOSE"; break; | | case MetaTrigger::CLOSE: kstr = "CLOSE"; break; | |
| case MetaTrigger::CLEAR: kstr = "CLEAR"; break; | | case MetaTrigger::CLEAR: kstr = "CLEAR"; break; | |
| case MetaTrigger::ITERATE: kstr = "ITERATE"; break; | | case MetaTrigger::ITERATE: kstr = "ITERATE"; break; | |
| case MetaTrigger::SYNCHRONIZE: kstr = "SYNCHRONIZE"; break; | | case MetaTrigger::SYNCHRONIZE: kstr = "SYNCHRONIZE"; break; | |
|
| | | case MetaTrigger::OCCUPY: kstr = "OCCUPY"; break; | |
| case MetaTrigger::BEGINTRAN: kstr = "BEGINTRAN"; break; | | case MetaTrigger::BEGINTRAN: kstr = "BEGINTRAN"; break; | |
| case MetaTrigger::COMMITTRAN: kstr = "COMMITTRAN"; break; | | case MetaTrigger::COMMITTRAN: kstr = "COMMITTRAN"; break; | |
| case MetaTrigger::ABORTTRAN: kstr = "ABORTTRAN"; break; | | case MetaTrigger::ABORTTRAN: kstr = "ABORTTRAN"; break; | |
| case MetaTrigger::MISC: kstr = "MISC"; break; | | case MetaTrigger::MISC: kstr = "MISC"; break; | |
| } | | } | |
| if (!prefix_.empty()) *strm_ << prefix_ << ": "; | | if (!prefix_.empty()) *strm_ << prefix_ << ": "; | |
| *strm_ << "[" << kstr << "]: " << message << std::endl; | | *strm_ << "[" << kstr << "]: " << message << std::endl; | |
| } | | } | |
| private: | | private: | |
| std::ostream* strm_; ///< output stream | | std::ostream* strm_; ///< output stream | |
| | | | |
End of changes. 3 change blocks. |
| 0 lines changed or deleted | | 26 lines changed or added | |
|
| kcprotodb.h | | kcprotodb.h | |
| | | | |
| skipping to change at line 687 | | skipping to change at line 687 | |
| trigger_meta(MetaTrigger::CLOSE, "close"); | | trigger_meta(MetaTrigger::CLOSE, "close"); | |
| return true; | | return true; | |
| } | | } | |
| /** | | /** | |
| * Synchronize updated contents with the file and the device. | | * Synchronize updated contents with the file and the device. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | | * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | |
| * @param checker a progress checker object. If it is NULL, no checking
is performed. | | * @param checker a progress checker object. If it is NULL, no checking
is performed. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
|
| | | * @note The operation of the postprocessor is performed atomically and o | |
| | | ther threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| */ | | */ | |
| bool synchronize(bool hard = false, FileProcessor* proc = NULL, | | bool synchronize(bool hard = false, FileProcessor* proc = NULL, | |
| ProgressChecker* checker = NULL) { | | ProgressChecker* checker = NULL) { | |
| _assert_(true); | | _assert_(true); | |
| ScopedSpinRWLock lock(&mlock_, false); | | ScopedSpinRWLock lock(&mlock_, false); | |
| if (omode_ == 0) { | | if (omode_ == 0) { | |
| set_error(_KCCODELINE_, Error::INVALID, "not opened"); | | set_error(_KCCODELINE_, Error::INVALID, "not opened"); | |
| return false; | | return false; | |
| } | | } | |
| bool err = false; | | bool err = false; | |
| | | | |
| skipping to change at line 716 | | skipping to change at line 719 | |
| } | | } | |
| if (!proc->process(path_, recs_.size(), size_)) { | | if (!proc->process(path_, recs_.size(), size_)) { | |
| set_error(_KCCODELINE_, Error::LOGIC, "postprocessing failed"); | | set_error(_KCCODELINE_, Error::LOGIC, "postprocessing failed"); | |
| err = true; | | err = true; | |
| } | | } | |
| } | | } | |
| trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | | trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
|
| | | * Occupy database by locking and do something meanwhile. | |
| | | * @param writable true to use writer lock, or false to use reader lock. | |
| | | * @param proc a processor object. If it is NULL, no processing is perfo | |
| | | rmed. | |
| | | * @return true on success, or false on failure. | |
| | | * @note The operation of the processor is performed atomically and other | |
| | | threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| | | */ | |
| | | bool occupy(bool writable = true, FileProcessor* proc = NULL) { | |
| | | _assert_(true); | |
| | | ScopedSpinRWLock lock(&mlock_, writable); | |
| | | bool err = false; | |
| | | if (proc && !proc->process(path_, recs_.size(), size_)) { | |
| | | set_error(_KCCODELINE_, Error::LOGIC, "processing failed"); | |
| | | err = true; | |
| | | } | |
| | | trigger_meta(MetaTrigger::OCCUPY, "occupy"); | |
| | | return !err; | |
| | | } | |
| | | /** | |
| * Begin transaction. | | * Begin transaction. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| bool begin_transaction(bool hard = false) { | | bool begin_transaction(bool hard = false) { | |
| _assert_(true); | | _assert_(true); | |
| uint32_t wcnt = 0; | | uint32_t wcnt = 0; | |
| while (true) { | | while (true) { | |
| mlock_.lock_writer(); | | mlock_.lock_writer(); | |
| | | | |
| skipping to change at line 1077 | | skipping to change at line 1100 | |
| explicit TranLog(const std::string& pkey, const std::string& pvalue) : | | explicit TranLog(const std::string& pkey, const std::string& pvalue) : | |
| full(true), key(pkey), value(pvalue) { | | full(true), key(pkey), value(pvalue) { | |
| _assert_(true); | | _assert_(true); | |
| } | | } | |
| /** constructor for an empty record */ | | /** constructor for an empty record */ | |
| explicit TranLog(const std::string& pkey) : full(false), key(pkey) { | | explicit TranLog(const std::string& pkey) : full(false), key(pkey) { | |
| _assert_(true); | | _assert_(true); | |
| } | | } | |
| }; | | }; | |
| /** | | /** | |
|
| * Scoped visiotor. | | * Scoped visitor. | |
| */ | | */ | |
| class ScopedVisitor { | | class ScopedVisitor { | |
| public: | | public: | |
| /** constructor */ | | /** constructor */ | |
|
| ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | | explicit ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | |
| _assert_(visitor); | | _assert_(visitor); | |
| visitor_->visit_before(); | | visitor_->visit_before(); | |
| } | | } | |
| /** destructor */ | | /** destructor */ | |
| ~ScopedVisitor() { | | ~ScopedVisitor() { | |
| _assert_(true); | | _assert_(true); | |
| visitor_->visit_after(); | | visitor_->visit_after(); | |
| } | | } | |
| private: | | private: | |
| Visitor* visitor_; ///< visitor | | Visitor* visitor_; ///< visitor | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 30 lines changed or added | |
|
| kcstashdb.h | | kcstashdb.h | |
| | | | |
| skipping to change at line 595 | | skipping to change at line 595 | |
| trigger_meta(MetaTrigger::CLOSE, "close"); | | trigger_meta(MetaTrigger::CLOSE, "close"); | |
| return true; | | return true; | |
| } | | } | |
| /** | | /** | |
| * Synchronize updated contents with the file and the device. | | * Synchronize updated contents with the file and the device. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | | * @param proc a postprocessor object. If it is NULL, no postprocessing
is performed. | |
| * @param checker a progress checker object. If it is NULL, no checking
is performed. | | * @param checker a progress checker object. If it is NULL, no checking
is performed. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
|
| | | * @note The operation of the postprocessor is performed atomically and o | |
| | | ther threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| */ | | */ | |
| bool synchronize(bool hard = false, FileProcessor* proc = NULL, | | bool synchronize(bool hard = false, FileProcessor* proc = NULL, | |
| ProgressChecker* checker = NULL) { | | ProgressChecker* checker = NULL) { | |
| _assert_(true); | | _assert_(true); | |
| ScopedSpinRWLock lock(&mlock_, false); | | ScopedSpinRWLock lock(&mlock_, false); | |
| if (omode_ == 0) { | | if (omode_ == 0) { | |
| set_error(_KCCODELINE_, Error::INVALID, "not opened"); | | set_error(_KCCODELINE_, Error::INVALID, "not opened"); | |
| return false; | | return false; | |
| } | | } | |
| bool err = false; | | bool err = false; | |
| | | | |
| skipping to change at line 624 | | skipping to change at line 627 | |
| } | | } | |
| if (!proc->process(path_, count_, size_impl())) { | | if (!proc->process(path_, count_, size_impl())) { | |
| set_error(_KCCODELINE_, Error::LOGIC, "postprocessing failed"); | | set_error(_KCCODELINE_, Error::LOGIC, "postprocessing failed"); | |
| err = true; | | err = true; | |
| } | | } | |
| } | | } | |
| trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | | trigger_meta(MetaTrigger::SYNCHRONIZE, "synchronize"); | |
| return !err; | | return !err; | |
| } | | } | |
| /** | | /** | |
|
| | | * Occupy database by locking and do something meanwhile. | |
| | | * @param writable true to use writer lock, or false to use reader lock. | |
| | | * @param proc a processor object. If it is NULL, no processing is perfo | |
| | | rmed. | |
| | | * @return true on success, or false on failure. | |
| | | * @note The operation of the processor is performed atomically and other | |
| | | threads accessing | |
| | | * the same record are blocked. To avoid deadlock, any explicit database | |
| | | operation must not | |
| | | * be performed in this function. | |
| | | */ | |
| | | bool occupy(bool writable = true, FileProcessor* proc = NULL) { | |
| | | _assert_(true); | |
| | | ScopedSpinRWLock lock(&mlock_, writable); | |
| | | bool err = false; | |
| | | if (proc && !proc->process(path_, count_, size_impl())) { | |
| | | set_error(_KCCODELINE_, Error::LOGIC, "processing failed"); | |
| | | err = true; | |
| | | } | |
| | | trigger_meta(MetaTrigger::OCCUPY, "occupy"); | |
| | | return !err; | |
| | | } | |
| | | /** | |
| * Begin transaction. | | * Begin transaction. | |
| * @param hard true for physical synchronization with the device, or fals
e for logical | | * @param hard true for physical synchronization with the device, or fals
e for logical | |
| * synchronization with the file system. | | * synchronization with the file system. | |
| * @return true on success, or false on failure. | | * @return true on success, or false on failure. | |
| */ | | */ | |
| bool begin_transaction(bool hard = false) { | | bool begin_transaction(bool hard = false) { | |
| _assert_(true); | | _assert_(true); | |
| uint32_t wcnt = 0; | | uint32_t wcnt = 0; | |
| while (true) { | | while (true) { | |
| mlock_.lock_writer(); | | mlock_.lock_writer(); | |
| | | | |
| skipping to change at line 1115 | | skipping to change at line 1138 | |
| class Remover : public Visitor { | | class Remover : public Visitor { | |
| private: | | private: | |
| /** visit a record */ | | /** visit a record */ | |
| const char* visit_full(const char* kbuf, size_t ksiz, | | const char* visit_full(const char* kbuf, size_t ksiz, | |
| const char* vbuf, size_t vsiz, size_t* sp) { | | const char* vbuf, size_t vsiz, size_t* sp) { | |
| _assert_(kbuf && ksiz <= MEMMAXSIZ && vbuf && vsiz <= MEMMAXSIZ && sp
); | | _assert_(kbuf && ksiz <= MEMMAXSIZ && vbuf && vsiz <= MEMMAXSIZ && sp
); | |
| return REMOVE; | | return REMOVE; | |
| } | | } | |
| }; | | }; | |
| /** | | /** | |
|
| * Scoped visiotor. | | * Scoped visitor. | |
| */ | | */ | |
| class ScopedVisitor { | | class ScopedVisitor { | |
| public: | | public: | |
| /** constructor */ | | /** constructor */ | |
|
| ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | | explicit ScopedVisitor(Visitor* visitor) : visitor_(visitor) { | |
| _assert_(visitor); | | _assert_(visitor); | |
| visitor_->visit_before(); | | visitor_->visit_before(); | |
| } | | } | |
| /** destructor */ | | /** destructor */ | |
| ~ScopedVisitor() { | | ~ScopedVisitor() { | |
| _assert_(true); | | _assert_(true); | |
| visitor_->visit_after(); | | visitor_->visit_after(); | |
| } | | } | |
| private: | | private: | |
| Visitor* visitor_; ///< visitor | | Visitor* visitor_; ///< visitor | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 30 lines changed or added | |
|