-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cxx
101 lines (78 loc) · 2.03 KB
/
Main.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "Throttle.h"
#include <time.h>
#include <iostream>
#include "DBConnectionPtr.h"
#ifdef _WINDOWS
#include <windows.h>
#else
#include <unistd.h>
#endif
#include "DBPool.h"
#include "DBPoolTestCase.h"
#include "TextRunner.h"
using namespace std;
void throttle();
void testPassByReference(DBConnectionPtr& ptr);
void testPassByValue(DBConnectionPtr ptr);
int main(int argc, char** argv)
{
//TestTemplate<DBPoolTestCase> myTest(DBPoolTestCase::test1, "Test 1");
TextRunner<DBPoolTestCase> myTest;
myTest.run();
/*
// DBPOOL TEST STUFF
DBPoolTestCase testCase;
if (testCase.run())
{
cout << "All test passed" << "\n";
}
else
{
cout << "A test failed" << "\n";
}
*/
// throttle();
}
void testDBConnectionPtr()
{
// get a connection
DBConnectionPtr connection = DBPool::getInstance().getConnection();
// test passing it by reference
testPassByReference(connection);
// test passing by value
testPassByValue(connection);
}
//-------------------------------------------------------------------
// Test routine for smart point pass by reference
void testPassByReference(DBConnectionPtr& ptr)
{
cout << "In method passed by reference" << "\n";
cout << "Reference count " << ptr.getReferenceCount() << "\n";
}
//-------------------------------------------------------------------
// Test routine for smart point pass by value
void testPassByValue(DBConnectionPtr ptr)
{
cout << "In method passed by value" << "\n";
cout << "Reference count " << ptr.getReferenceCount() << "\n";
}
void throttle()
{
Throttle throttle;
throttle.throttle();
// now throttle again immediately
throttle.throttle();
// now wait a period of time
#ifdef _WINDOWS
Sleep(7 * 1000);
#else
time_t start;
time_t current;
time(&start);
do {
time(¤t);
} while (difftime(current, start) < 7);
// sleep(7);
#endif
throttle.throttle();
}