fix :error

This commit is contained in:
tqcq 2024-10-26 10:38:52 +00:00
parent c99dba25d2
commit 0d63164beb

View File

@ -346,14 +346,15 @@ find_row_mask(std::vector<set_t> &sets,
for (int i = 0; i < thread_num; ++i) {
workers.emplace_back([&] {
while (!found) {
uint64_t cur_mask = last_mask;
uint64_t cur_mask = 0;
uint64_t step_count = 0;
uint64_t my_pos = 0;
{
std::lock_guard<std::mutex> _(lock);
if (row_mask >= last_mask || found) { break; }
cur_mask = row_mask;
if (row_mask >= last_mask || found) { return; }
step_count = g_cur_pos - g_base_pos;
cur_mask = row_mask;
my_pos = g_cur_pos.fetch_add(step);
}
while (cur_mask < last_mask && step_count > 0 && !found.load(std::memory_order_relaxed)) {
@ -369,15 +370,15 @@ find_row_mask(std::vector<set_t> &sets,
step_count -= std::min(step_count, step);
if (my_pos > g_base_pos.load(std::memory_order_relaxed)) {
if (my_pos > g_base_pos.load(std::memory_order_relaxed) + step_count) {
std::lock_guard<std::mutex> _(lock);
if (my_pos > g_base_pos) {
if (my_pos > g_base_pos + step_count) {
g_base_pos = my_pos;
row_mask = cur_mask;
}
} else if (g_base_pos.load(std::memory_order_relaxed) < my_pos) {
} else {
std::lock_guard<std::mutex> _(lock);
if (g_base_pos <= my_pos) {
if (g_base_pos + step_count <= my_pos) {
cur_mask = row_mask;
step_count = my_pos - g_base_pos;
}