📄 controlstructure.cpp
字号:
/********************************************************************************************MiraXT -- Copyright (c) 2007, Tobias Schubert, Matthew Lewis, Natalia Kalinnik, Bernd Becker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies orsubstantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.********************************************************************************************/// Definition of the MiraXTmini overall control structure.class ControlStructure{private: pthread_mutex_t done_mutex; pthread_cond_t stats_cond; public: clauseDB* theClauseDB; // The clause database. int numThreads; // Number of threads. int masterDone; // masterDone != 0 --> stop search process. int* Solution; // If a satisfying assignment has found, "Solution" stores this assignment. bool SAT; // Status of the search: false = "unsat/aborted", true = "sat". long long startTime; // Timestamp at which the search process was started. // Constructor. ControlStructure(int Threads, clauseDB* tmpClauseDB, long long tmpStartTime) { numThreads = Threads; theClauseDB = tmpClauseDB; masterDone = 0; startTime = tmpStartTime; SAT = false; Solution = new (int [numLiterals+1]); pthread_mutex_init(&done_mutex, NULL); pthread_cond_init(&stats_cond, NULL); } // Destructor. ~ControlStructure(void) { delete [] Solution; } // Increments the variable "masterDone" to indicate the end of the // search process. All threads periodically check the status of // masterDone and stop their search if masterDone is not equal 0. void done(void) { pthread_mutex_lock(&done_mutex); masterDone++; pthread_cond_signal(&stats_cond); pthread_mutex_unlock(&done_mutex); } // If a thread has found a satisfying assignment, this // assignment is copied into "Solution". void problemSolved(int* threadAssignment) { pthread_mutex_lock(&done_mutex); for (int i=0; i<=numLiterals; i++) { Solution[i] = threadAssignment[i]; } SAT = true; pthread_mutex_unlock( &done_mutex ); } };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -