// // libsemigroups - C++ library for semigroups and monoids // Copyright (C) 2019 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //
void ThreadIdManager::reset() { // Only do this from the main thread
LIBSEMIGROUPS_ASSERT(tid(std::this_thread::get_id()) == 0); // Delete all thread_ids
_thread_map.clear();
_next_tid = 0; // Reinsert the main thread's id
tid(std::this_thread::get_id());
}
size_t ThreadIdManager::tid(std::thread::id t) {
std::lock_guard<std::mutex> lg(_mtx); auto it = _thread_map.find(t); if (it != _thread_map.end()) { return (*it).second;
} else { // Don't check the assert below because on a single thread machine // (such as those used by appveyor), for an fp-semigroup more than 1 // thread will be used, and this assertion will fail. // LIBSEMIGROUPS_ASSERT(_next_tid <= // std::thread::hardware_concurrency());
_thread_map.emplace(t, _next_tid++); return _next_tid - 1;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.