Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent load disk when cs starts #880 #882

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

lylei
Copy link
Collaborator

@lylei lylei commented Mar 17, 2017

(#880)

@@ -20,16 +20,20 @@ class DataBlockTest : public ::testing::Test {
protected:
};

void AddBlock(int64_t block_id, Disk* disk, BlockMeta meta) {
void AdBlock(int64_t block_id, Disk* disk, BlockMeta meta) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥删个字母?因为符号冲突了?

// return value from Disk::LoadStorage:
// 0: initial state, 1: done, -1: error occured
std::vector<int> ret_vals;
ret_vals.resize(disks_.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能保证初始值是0不?

@@ -165,15 +165,46 @@ int64_t BlockManager::DiskQuota() const {

// TODO: concurrent load
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

// return value from Disk::LoadStorage:
// 0: initial state, 1: done, -1: error occured
std::vector<int> ret_vals;
ret_vals.resize(disks_.size(), 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以直接写成
std::vector ret_vals(disks_.size(), 0);

std::placeholders::_3));
disk_quota_ += disk->GetQuota();
std::placeholders::_3);
tp.AddTask(std::bind(&Disk::LoadStorage, disk, callback, &(ret_vals[disk_index])));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用不着这么多层括号吧, &ret_vals[disk_index]应该就是可以的

}
bool ret = true;
while (true) {
sleep(1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉没必要上来就sleep一秒, 说不定已经完成了呢
sleep可以放循环的最后

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants