Skip to content

Commit

Permalink
Voidify sweep().
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yata committed Jul 18, 2013
1 parent 38b2fb8 commit c97797a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/grnxx/map/bytes_array.cpp
Expand Up @@ -110,8 +110,8 @@ void BytesArray::set(uint64_t value_id, ValueArg value) {
*src_bytes_id = dest_bytes_id;
}

bool BytesArray::sweep(Duration lifetime) {
return pool_->sweep(lifetime);
void BytesArray::sweep(Duration lifetime) {
pool_->sweep(lifetime);
}

BytesArray::BytesArray()
Expand Down
2 changes: 1 addition & 1 deletion lib/grnxx/map/bytes_array.hpp
Expand Up @@ -75,7 +75,7 @@ class BytesArray {
void set(uint64_t value_id, ValueArg value);

// Sweep empty pages whose modified time < (now - lifetime).
bool sweep(Duration lifetime);
void sweep(Duration lifetime);

private:
Storage *storage_;
Expand Down
7 changes: 3 additions & 4 deletions lib/grnxx/map/bytes_pool.cpp
Expand Up @@ -203,10 +203,10 @@ uint64_t BytesPool::add(ValueArg value) {
return get_value_id(offset, size);
}

bool BytesPool::sweep(Duration lifetime) {
void BytesPool::sweep(Duration lifetime) {
if (header_->latest_empty_page_id == INVALID_PAGE_ID) {
// Nothing to do.
return true;
return;
}
BytesPoolPageHeader * const latest_empty_page_header =
&page_headers_->get_value(header_->latest_empty_page_id);
Expand All @@ -223,7 +223,7 @@ bool BytesPool::sweep(Duration lifetime) {
}
if (oldest_empty_page_header->modified_time > threshold) {
// The remaining empty pages are not ready.
return true;
break;
}
const uint32_t next_oldest_empty_page_id =
oldest_empty_page_header->next_page_id;
Expand All @@ -234,7 +234,6 @@ bool BytesPool::sweep(Duration lifetime) {
header_->latest_empty_page_id = INVALID_PAGE_ID;
}
} while (header_->latest_empty_page_id != INVALID_PAGE_ID);
return true;
}

BytesPool::~BytesPool() {}
Expand Down
2 changes: 1 addition & 1 deletion lib/grnxx/map/bytes_pool.hpp
Expand Up @@ -129,7 +129,7 @@ class BytesPool {
}

// Sweep empty pages whose modified time <= (now - lifetime).
bool sweep(Duration lifetime);
void sweep(Duration lifetime);

private:
Storage *storage_;
Expand Down
4 changes: 2 additions & 2 deletions test/test_map.cpp
Expand Up @@ -247,15 +247,15 @@ void test_bytes_pool_sweep() {
std::uint64_t key_id = pool->add(keys[i]);
pool->unset(key_id);
}
assert(pool->sweep(grnxx::Duration(0)));
pool->sweep(grnxx::Duration(0));
for (std::uint64_t i = 0; i < BYTES_POOL_NUM_KEYS; ++i) {
std::uint64_t key_id = pool->add(keys[i]);
key_ids.push_back(key_id);
}
for (std::uint64_t i = 0; i < BYTES_POOL_NUM_KEYS; ++i) {
pool->unset(key_ids[i]);
}
assert(pool->sweep(grnxx::Duration(0)));
pool->sweep(grnxx::Duration(0));
}

void test_bytes_array_create() {
Expand Down

0 comments on commit c97797a

Please sign in to comment.