This commit is contained in:
tqcq 2024-10-24 05:15:37 +00:00
parent 9a0c0f77da
commit 47bf8cc0d9

View File

@ -330,20 +330,26 @@ find_row_mask(std::vector<set_t> &sets,
if (thread_num > 2) { thread_num -= 2; }
for (int i = 0; i < thread_num; ++i) {
workers.emplace_back([&] {
std::vector<uint64_t> masks;
while (!found) {
uint64_t cur_mask = last_mask;
{
masks.clear();
std::lock_guard<std::mutex> _(lock);
cur_mask = row_mask;
for (int i = 0; i < 10000 && row_mask < last_mask; ++i) {
masks.push_back(row_mask);
row_mask = next_bit_permutation(row_mask);
}
if (row_mask >= last_mask) { break; }
row_mask = next_bit_permutation(row_mask);
// verbose_printerr("[LOG] - Cur Row mask: 0x%0lx \t\t bits: %s\n", cur_mask, bit_string(cur_mask));
}
if (resolve(cur_mask, found)) {
std::lock_guard<std::mutex> _(lock);
if (!found.exchange(true)) { row_mask = cur_mask; }
for (const auto &cur_mask : masks) {
if (resolve(cur_mask, found)) {
std::lock_guard<std::mutex> _(lock);
if (!found.exchange(true)) {
row_mask = cur_mask;
break;
}
}
}
}
});