Skip to content

Commit

Permalink
assertマクロ内で副作用のある関数を呼び出していた箇所を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
sile committed Sep 25, 2012
1 parent dec111b commit 9c34b06
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -8,7 +8,7 @@
* プロジェクトページ: https://github.com/sile/ipc-msgque

## バージョン
* 0.1.1
* 0.1.2

## 対応環境
* gccのver4.1以上
Expand Down
3 changes: 2 additions & 1 deletion include/imque/allocator/variable_allocator.hh
Expand Up @@ -182,7 +182,8 @@ namespace imque {

node.version++;
node.setRefCount(1);
assert(snap.compare_and_swap(node)); // 他と競合するような使い方をしてはいけない
bool rlt = snap.compare_and_swap(node); // 他と競合するような使い方をしてはいけない
assert(rlt);

desc.version++;
return desc.encode();
Expand Down
17 changes: 11 additions & 6 deletions include/imque/queue/queue_impl.hh
Expand Up @@ -10,7 +10,7 @@

namespace imque {
namespace queue {
static const char MAGIC[] = "IMQUE-0.1.1";
static const char MAGIC[] = "IMQUE-0.1.2";

// FIFOキュー
class QueueImpl {
Expand Down Expand Up @@ -45,7 +45,8 @@ namespace imque {

~NodeRef() {
if(md_) {
assert(alc_.release(md_));
bool rlt = alc_.release(md_);
assert(rlt);
}
}

Expand Down Expand Up @@ -88,7 +89,8 @@ namespace imque {

que_->head = sentinel;
que_->tail = sentinel;
assert(alc_.dup(sentinel)); // head と tail の二箇所から参照されているので、参照カウントを一つ増やしておく
bool rlt = alc_.dup(sentinel); // head と tail の二箇所から参照されているので、参照カウントを一つ増やしておく
assert(rlt);

que_->overflowed_count = 0;
}
Expand Down Expand Up @@ -146,7 +148,8 @@ namespace imque {
Node* node = alc_.ptr<Node>(md);
buf.assign(node->data, node->data_size);

assert(alc_.release(md));
bool rlt = alc_.release(md);
assert(rlt);
return true;
}

Expand All @@ -170,7 +173,8 @@ namespace imque {

private:
void enqImpl(uint32_t new_tail) {
assert(alc_.dup(new_tail, 2)); // head と tail からの参照分を始めにカウントしておく
bool rlt = alc_.dup(new_tail, 2); // head と tail からの参照分を始めにカウントしておく
assert(rlt);

for(;;) {
NodeRef tail_ref(que_->tail, alc_);
Expand Down Expand Up @@ -212,7 +216,8 @@ namespace imque {

bool tryMoveNext(volatile uint32_t* place, uint32_t curr, uint32_t next) {
if(atomic::compare_and_swap(place, curr, next)) {
assert(alc_.release(curr));
bool rlt = alc_.release(curr);
assert(rlt);
return true;
}
return false;
Expand Down

0 comments on commit 9c34b06

Please sign in to comment.