Debian Codegraph @

Source/Test/CConcurrentOccurenceUnsatisfiableCacheTester.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CConcurrentOccurenceUnsatisfiableCacheTester.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28
29
30 CConcurrentOccurenceUnsatisfiableCacheTester::CConcurrentOccurenceUnsatisfiableCacheTester() {
31 occUnsatCache = 0;
32 writer = 0;
33 }
34
35
36 CConcurrentOccurenceUnsatisfiableCacheTester::~CConcurrentOccurenceUnsatisfiableCacheTester() {
37 qDeleteAll(readerList);
38 if (writer) {
39 delete writer;
40 }
41 if (occUnsatCache) {
42 delete occUnsatCache;
43 }
44 }
45
46
47 void CConcurrentOccurenceUnsatisfiableCacheTester::generateCacheStructure(qint64 cacheReaderCount) {
48 readerCount = cacheReaderCount;
49 if (occUnsatCache) {
50 delete occUnsatCache;
51 }
52 if (writer) {
53 delete writer;
54 }
55 qDeleteAll(readerList);
56 readerList.clear();
57 occUnsatCache = new COccurrenceUnsatisfiableCache(readerCount+2);
58 writer = new CCacheTestWriter(new COccurrenceUnsatisfiableCacheWriter(occUnsatCache));
59
60 for (qint64 i = 0; i < cacheReaderCount; ++i) {
61 CCacheTestReader *reader = new CCacheTestReader(occUnsatCache->getCacheReader());
62 readerList.append(reader);
63 }
64 }
65
66 void CConcurrentOccurenceUnsatisfiableCacheTester::runCacheTest() {
67 foreach (CCacheTestReader *reader, readerList) {
68 reader->startReader();
69 }
70 if (writer) {
71 writer->startWriter();
72 }
73 }
74
75 qint64 CConcurrentOccurenceUnsatisfiableCacheTester::getCacheWrites() {
76 if (writer) {
77 return writer->getCacheWrites();
78 } else {
79 return 0;
80 }
81 }
82
83 qint64 CConcurrentOccurenceUnsatisfiableCacheTester::getCacheReads() {
84 qint64 cacheReads = 0;
85 foreach (CCacheTestReader *reader, readerList) {
86 cacheReads = reader->getCacheReads();
87 }
88 return cacheReads;
89 }
90
91
92
93 }; // end namespace Test
94
95 }; // end namespace Konclude