THRIFT-2729: C++ - .clang-format created and applied
Client: C++
Patch: Konrad Grochowski
make style command added
diff --git a/lib/cpp/test/concurrency/Tests.cpp b/lib/cpp/test/concurrency/Tests.cpp
index c80bb88..0d81d7e 100644
--- a/lib/cpp/test/concurrency/Tests.cpp
+++ b/lib/cpp/test/concurrency/Tests.cpp
@@ -29,7 +29,7 @@
std::string arg;
- std::vector<std::string> args(argc - 1 > 1 ? argc - 1 : 1);
+ std::vector<std::string> args(argc - 1 > 1 ? argc - 1 : 1);
args[0] = "all";
@@ -45,9 +45,9 @@
std::cout << "ThreadFactory tests..." << std::endl;
- size_t count = 1000;
- size_t floodLoops = 1;
- size_t floodCount = 100000;
+ size_t count = 1000;
+ size_t floodLoops = 1;
+ size_t floodCount = 100000;
std::cout << "\t\tThreadFactory reap N threads test: N = " << count << std::endl;
@@ -89,7 +89,6 @@
std::cout << "\t\t\tscall per ms: " << count / (time01 - time00) << std::endl;
}
-
if (runAll || args[0].compare("timer-manager") == 0) {
std::cout << "TimerManager tests..." << std::endl;
@@ -113,16 +112,17 @@
int64_t delay = 10LL;
- std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl;
+ std::cout << "\t\tThreadManager load test: worker count: " << workerCount
+ << " task count: " << taskCount << " delay: " << delay << std::endl;
ThreadManagerTests threadManagerTests;
assert(threadManagerTests.loadTest(taskCount, delay, workerCount));
- std::cout << "\t\tThreadManager block test: worker count: " << workerCount << " delay: " << delay << std::endl;
+ std::cout << "\t\tThreadManager block test: worker count: " << workerCount
+ << " delay: " << delay << std::endl;
assert(threadManagerTests.blockTest(delay, workerCount));
-
}
}
@@ -140,11 +140,12 @@
int64_t delay = 10LL;
- for (size_t workerCount = minWorkerCount; workerCount < maxWorkerCount; workerCount*= 2) {
+ for (size_t workerCount = minWorkerCount; workerCount < maxWorkerCount; workerCount *= 2) {
size_t taskCount = workerCount * tasksPerWorker;
- std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl;
+ std::cout << "\t\tThreadManager load test: worker count: " << workerCount
+ << " task count: " << taskCount << " delay: " << delay << std::endl;
ThreadManagerTests threadManagerTests;
diff --git a/lib/cpp/test/concurrency/ThreadFactoryTests.h b/lib/cpp/test/concurrency/ThreadFactoryTests.h
old mode 100755
new mode 100644
index 2d97337..d7431a8
--- a/lib/cpp/test/concurrency/ThreadFactoryTests.h
+++ b/lib/cpp/test/concurrency/ThreadFactoryTests.h
@@ -27,7 +27,10 @@
#include <iostream>
#include <set>
-namespace apache { namespace thrift { namespace concurrency { namespace test {
+namespace apache {
+namespace thrift {
+namespace concurrency {
+namespace test {
using boost::shared_ptr;
using namespace apache::thrift::concurrency;
@@ -40,18 +43,14 @@
class ThreadFactoryTests {
public:
-
static const double TEST_TOLERANCE;
- class Task: public Runnable {
+ class Task : public Runnable {
public:
-
Task() {}
- void run() {
- std::cout << "\t\t\tHello World" << std::endl;
- }
+ void run() { std::cout << "\t\t\tHello World" << std::endl; }
};
/**
@@ -77,20 +76,17 @@
/**
* Reap N threads
*/
- class ReapNTask: public Runnable {
+ class ReapNTask : public Runnable {
- public:
-
- ReapNTask(Monitor& monitor, int& activeCount) :
- _monitor(monitor),
- _count(activeCount) {}
+ public:
+ ReapNTask(Monitor& monitor, int& activeCount) : _monitor(monitor), _count(activeCount) {}
void run() {
Synchronized s(_monitor);
_count--;
- //std::cout << "\t\t\tthread count: " << _count << std::endl;
+ // std::cout << "\t\t\tthread count: " << _count << std::endl;
if (_count == 0) {
_monitor.notify();
@@ -102,15 +98,15 @@
int& _count;
};
- bool reapNThreads(int loop=1, int count=10) {
+ bool reapNThreads(int loop = 1, int count = 10) {
- PlatformThreadFactory threadFactory = PlatformThreadFactory();
+ PlatformThreadFactory threadFactory = PlatformThreadFactory();
Monitor* monitor = new Monitor();
- for(int lix = 0; lix < loop; lix++) {
+ for (int lix = 0; lix < loop; lix++) {
- int* activeCount = new int(count);
+ int* activeCount = new int(count);
std::set<shared_ptr<Thread> > threads;
@@ -118,20 +114,25 @@
for (tix = 0; tix < count; tix++) {
try {
- threads.insert(threadFactory.newThread(shared_ptr<Runnable>(new ReapNTask(*monitor, *activeCount))));
- } catch(SystemResourceException& e) {
- std::cout << "\t\t\tfailed to create " << lix * count + tix << " thread " << e.what() << std::endl;
+ threads.insert(
+ threadFactory.newThread(shared_ptr<Runnable>(new ReapNTask(*monitor, *activeCount))));
+ } catch (SystemResourceException& e) {
+ std::cout << "\t\t\tfailed to create " << lix* count + tix << " thread " << e.what()
+ << std::endl;
throw e;
}
}
tix = 0;
- for (std::set<shared_ptr<Thread> >::const_iterator thread = threads.begin(); thread != threads.end(); tix++, ++thread) {
+ for (std::set<shared_ptr<Thread> >::const_iterator thread = threads.begin();
+ thread != threads.end();
+ tix++, ++thread) {
try {
(*thread)->start();
- } catch(SystemResourceException& e) {
- std::cout << "\t\t\tfailed to start " << lix * count + tix << " thread " << e.what() << std::endl;
+ } catch (SystemResourceException& e) {
+ std::cout << "\t\t\tfailed to start " << lix* count + tix << " thread " << e.what()
+ << std::endl;
throw e;
}
}
@@ -143,7 +144,7 @@
}
}
delete activeCount;
- std::cout << "\t\t\treaped " << lix * count << " threads" << std::endl;
+ std::cout << "\t\t\treaped " << lix* count << " threads" << std::endl;
}
std::cout << "\t\t\tSuccess!" << std::endl;
@@ -151,21 +152,12 @@
return true;
}
- class SynchStartTask: public Runnable {
+ class SynchStartTask : public Runnable {
- public:
+ public:
+ enum STATE { UNINITIALIZED, STARTING, STARTED, STOPPING, STOPPED };
- enum STATE {
- UNINITIALIZED,
- STARTING,
- STARTED,
- STOPPING,
- STOPPED
- };
-
- SynchStartTask(Monitor& monitor, volatile STATE& state) :
- _monitor(monitor),
- _state(state) {}
+ SynchStartTask(Monitor& monitor, volatile STATE& state) : _monitor(monitor), _state(state) {}
void run() {
{
@@ -189,9 +181,9 @@
}
}
- private:
+ private:
Monitor& _monitor;
- volatile STATE& _state;
+ volatile STATE& _state;
};
bool synchStartTest() {
@@ -200,9 +192,10 @@
SynchStartTask::STATE state = SynchStartTask::UNINITIALIZED;
- shared_ptr<SynchStartTask> task = shared_ptr<SynchStartTask>(new SynchStartTask(monitor, state));
+ shared_ptr<SynchStartTask> task
+ = shared_ptr<SynchStartTask>(new SynchStartTask(monitor, state));
- PlatformThreadFactory threadFactory = PlatformThreadFactory();
+ PlatformThreadFactory threadFactory = PlatformThreadFactory();
shared_ptr<Thread> thread = threadFactory.newThread(task);
@@ -226,8 +219,8 @@
Synchronized s(monitor);
try {
- monitor.wait(100);
- } catch(TimedOutException& e) {
+ monitor.wait(100);
+ } catch (TimedOutException& e) {
}
if (state == SynchStartTask::STARTED) {
@@ -253,7 +246,7 @@
/** See how accurate monitor timeout is. */
- bool monitorTimeoutTest(size_t count=1000, int64_t timeout=10) {
+ bool monitorTimeoutTest(size_t count = 1000, int64_t timeout = 10) {
Monitor monitor;
@@ -263,8 +256,8 @@
{
Synchronized s(monitor);
try {
- monitor.wait(timeout);
- } catch(TimedOutException& e) {
+ monitor.wait(timeout);
+ } catch (TimedOutException& e) {
}
}
}
@@ -273,31 +266,32 @@
double error = ((endTime - startTime) - (count * timeout)) / (double)(count * timeout);
- if (error < 0.0) {
+ if (error < 0.0) {
error *= 1.0;
}
bool success = error < ThreadFactoryTests::TEST_TOLERANCE;
- std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << count * timeout << "ms elapsed time: "<< endTime - startTime << "ms error%: " << error * 100.0 << std::endl;
+ std::cout << "\t\t\t" << (success ? "Success" : "Failure")
+ << "! expected time: " << count * timeout
+ << "ms elapsed time: " << endTime - startTime << "ms error%: " << error * 100.0
+ << std::endl;
return success;
}
-
class FloodTask : public Runnable {
public:
-
- FloodTask(const size_t id) :_id(id) {}
- ~FloodTask(){
- if(_id % 1000 == 0) {
+ FloodTask(const size_t id) : _id(id) {}
+ ~FloodTask() {
+ if (_id % 1000 == 0) {
std::cout << "\t\tthread " << _id << " done" << std::endl;
}
}
- void run(){
- if(_id % 1000 == 0) {
+ void run() {
+ if (_id % 1000 == 0) {
std::cout << "\t\tthread " << _id << " started" << std::endl;
}
@@ -306,42 +300,41 @@
const size_t _id;
};
- void foo(PlatformThreadFactory *tf) {
- (void) tf;
- }
+ void foo(PlatformThreadFactory* tf) { (void)tf; }
- bool floodNTest(size_t loop=1, size_t count=100000) {
+ bool floodNTest(size_t loop = 1, size_t count = 100000) {
bool success = false;
- for(size_t lix = 0; lix < loop; lix++) {
+ for (size_t lix = 0; lix < loop; lix++) {
PlatformThreadFactory threadFactory = PlatformThreadFactory();
threadFactory.setDetached(true);
- for(size_t tix = 0; tix < count; tix++) {
+ for (size_t tix = 0; tix < count; tix++) {
- try {
+ try {
- shared_ptr<FloodTask> task(new FloodTask(lix * count + tix ));
+ shared_ptr<FloodTask> task(new FloodTask(lix * count + tix));
- shared_ptr<Thread> thread = threadFactory.newThread(task);
+ shared_ptr<Thread> thread = threadFactory.newThread(task);
- thread->start();
+ thread->start();
- THRIFT_SLEEP_USEC(1);
+ THRIFT_SLEEP_USEC(1);
- } catch (TException& e) {
+ } catch (TException& e) {
- std::cout << "\t\t\tfailed to start " << lix * count + tix << " thread " << e.what() << std::endl;
+ std::cout << "\t\t\tfailed to start " << lix* count + tix << " thread " << e.what()
+ << std::endl;
- return success;
- }
+ return success;
}
+ }
- std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << std::endl;
+ std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << std::endl;
- success = true;
+ success = true;
}
return success;
@@ -349,5 +342,7 @@
};
const double ThreadFactoryTests::TEST_TOLERANCE = .20;
-
-}}}} // apache::thrift::concurrency::test
+}
+}
+}
+} // apache::thrift::concurrency::test
diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h
old mode 100755
new mode 100644
index c08448b..27bf6c5
--- a/lib/cpp/test/concurrency/ThreadManagerTests.h
+++ b/lib/cpp/test/concurrency/ThreadManagerTests.h
@@ -29,7 +29,10 @@
#include <set>
#include <stdint.h>
-namespace apache { namespace thrift { namespace concurrency { namespace test {
+namespace apache {
+namespace thrift {
+namespace concurrency {
+namespace test {
using namespace apache::thrift::concurrency;
@@ -38,15 +41,11 @@
static const double TEST_TOLERANCE;
public:
- class Task: public Runnable {
+ class Task : public Runnable {
public:
-
- Task(Monitor& monitor, size_t& count, int64_t timeout) :
- _monitor(monitor),
- _count(count),
- _timeout(timeout),
- _done(false) {}
+ Task(Monitor& monitor, size_t& count, int64_t timeout)
+ : _monitor(monitor), _count(count), _timeout(timeout), _done(false) {}
void run() {
@@ -57,9 +56,9 @@
try {
_sleep.wait(_timeout);
- } catch(TimedOutException& e) {
+ } catch (TimedOutException& e) {
;
- }catch(...) {
+ } catch (...) {
assert(0);
}
}
@@ -96,7 +95,7 @@
* completes. Verify that all tasks completed and that thread manager cleans
* up properly on delete.
*/
- bool loadTest(size_t count=100, int64_t timeout=100LL, size_t workerCount=4) {
+ bool loadTest(size_t count = 100, int64_t timeout = 100LL, size_t workerCount = 4) {
Monitor monitor;
@@ -104,7 +103,8 @@
shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
- shared_ptr<PlatformThreadFactory> threadFactory = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+ shared_ptr<PlatformThreadFactory> threadFactory
+ = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
#ifndef USE_BOOST_THREAD
threadFactory->setPriority(PosixThreadFactory::HIGHEST);
@@ -117,20 +117,23 @@
for (size_t ix = 0; ix < count; ix++) {
- tasks.insert(shared_ptr<ThreadManagerTests::Task>(new ThreadManagerTests::Task(monitor, activeCount, timeout)));
+ tasks.insert(shared_ptr<ThreadManagerTests::Task>(
+ new ThreadManagerTests::Task(monitor, activeCount, timeout)));
}
int64_t time00 = Util::currentTime();
- for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+ for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin();
+ ix != tasks.end();
+ ix++) {
- threadManager->add(*ix);
+ threadManager->add(*ix);
}
{
Synchronized s(monitor);
- while(activeCount > 0) {
+ while (activeCount > 0) {
monitor.wait();
}
@@ -145,7 +148,9 @@
int64_t minTime = 9223372036854775807LL;
int64_t maxTime = 0;
- for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+ for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin();
+ ix != tasks.end();
+ ix++) {
shared_ptr<ThreadManagerTests::Task> task = *ix;
@@ -169,43 +174,43 @@
maxTime = delta;
}
- averageTime+= delta;
+ averageTime += delta;
}
averageTime /= count;
- std::cout << "\t\t\tfirst start: " << firstTime << "ms Last end: " << lastTime << "ms min: " << minTime << "ms max: " << maxTime << "ms average: " << averageTime << "ms" << std::endl;
+ std::cout << "\t\t\tfirst start: " << firstTime << "ms Last end: " << lastTime
+ << "ms min: " << minTime << "ms max: " << maxTime << "ms average: " << averageTime
+ << "ms" << std::endl;
double expectedTime = ((count + (workerCount - 1)) / workerCount) * timeout;
double error = ((time01 - time00) - expectedTime) / expectedTime;
if (error < 0) {
- error*= -1.0;
+ error *= -1.0;
}
bool success = error < TEST_TOLERANCE;
- std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << expectedTime << "ms elapsed time: "<< time01 - time00 << "ms error%: " << error * 100.0 << std::endl;
+ std::cout << "\t\t\t" << (success ? "Success" : "Failure")
+ << "! expected time: " << expectedTime << "ms elapsed time: " << time01 - time00
+ << "ms error%: " << error * 100.0 << std::endl;
return success;
}
- class BlockTask: public Runnable {
+ class BlockTask : public Runnable {
public:
-
- BlockTask(Monitor& monitor, Monitor& bmonitor, size_t& count) :
- _monitor(monitor),
- _bmonitor(bmonitor),
- _count(count) {}
+ BlockTask(Monitor& monitor, Monitor& bmonitor, size_t& count)
+ : _monitor(monitor), _bmonitor(bmonitor), _count(count) {}
void run() {
{
Synchronized s(_bmonitor);
_bmonitor.wait();
-
}
{
@@ -229,8 +234,8 @@
* Block test. Create pendingTaskCountMax tasks. Verify that we block adding the
* pendingTaskCountMax + 1th task. Verify that we unblock when a task completes */
- bool blockTest(int64_t timeout=100LL, size_t workerCount=2) {
- (void) timeout;
+ bool blockTest(int64_t timeout = 100LL, size_t workerCount = 2) {
+ (void)timeout;
bool success = false;
try {
@@ -242,9 +247,11 @@
size_t activeCounts[] = {workerCount, pendingTaskMaxCount, 1};
- shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount, pendingTaskMaxCount);
+ shared_ptr<ThreadManager> threadManager
+ = ThreadManager::newSimpleThreadManager(workerCount, pendingTaskMaxCount);
- shared_ptr<PlatformThreadFactory> threadFactory = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+ shared_ptr<PlatformThreadFactory> threadFactory
+ = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
#ifndef USE_BOOST_THREAD
threadFactory->setPriority(PosixThreadFactory::HIGHEST);
@@ -257,43 +264,49 @@
for (size_t ix = 0; ix < workerCount; ix++) {
- tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(new ThreadManagerTests::BlockTask(monitor, bmonitor,activeCounts[0])));
+ tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(
+ new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[0])));
}
for (size_t ix = 0; ix < pendingTaskMaxCount; ix++) {
- tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(new ThreadManagerTests::BlockTask(monitor, bmonitor,activeCounts[1])));
+ tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(
+ new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[1])));
}
- for (std::set<shared_ptr<ThreadManagerTests::BlockTask> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+ for (std::set<shared_ptr<ThreadManagerTests::BlockTask> >::iterator ix = tasks.begin();
+ ix != tasks.end();
+ ix++) {
threadManager->add(*ix);
}
- if(!(success = (threadManager->totalTaskCount() == pendingTaskMaxCount + workerCount))) {
+ if (!(success = (threadManager->totalTaskCount() == pendingTaskMaxCount + workerCount))) {
throw TException("Unexpected pending task count");
}
- shared_ptr<ThreadManagerTests::BlockTask> extraTask(new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[2]));
+ shared_ptr<ThreadManagerTests::BlockTask> extraTask(
+ new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[2]));
try {
threadManager->add(extraTask, 1);
throw TException("Unexpected success adding task in excess of pending task count");
- } catch(TooManyPendingTasksException& e) {
+ } catch (TooManyPendingTasksException& e) {
throw TException("Should have timed out adding task in excess of pending task count");
- } catch(TimedOutException& e) {
+ } catch (TimedOutException& e) {
// Expected result
}
try {
threadManager->add(extraTask, -1);
throw TException("Unexpected success adding task in excess of pending task count");
- } catch(TimedOutException& e) {
+ } catch (TimedOutException& e) {
throw TException("Unexpected timeout adding task in excess of pending task count");
- } catch(TooManyPendingTasksException& e) {
+ } catch (TooManyPendingTasksException& e) {
// Expected result
}
- std::cout << "\t\t\t" << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
+ std::cout << "\t\t\t"
+ << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
{
Synchronized s(bmonitor);
@@ -304,21 +317,24 @@
{
Synchronized s(monitor);
- while(activeCounts[0] != 0) {
+ while (activeCounts[0] != 0) {
monitor.wait();
}
}
- std::cout << "\t\t\t" << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
+ std::cout << "\t\t\t"
+ << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
try {
threadManager->add(extraTask, 1);
- } catch(TimedOutException& e) {
- std::cout << "\t\t\t" << "add timed out unexpectedly" << std::endl;
+ } catch (TimedOutException& e) {
+ std::cout << "\t\t\t"
+ << "add timed out unexpectedly" << std::endl;
throw TException("Unexpected timeout adding task");
- } catch(TooManyPendingTasksException& e) {
- std::cout << "\t\t\t" << "add encountered too many pending exepctions" << std::endl;
+ } catch (TooManyPendingTasksException& e) {
+ std::cout << "\t\t\t"
+ << "add encountered too many pending exepctions" << std::endl;
throw TException("Unexpected timeout adding task");
}
@@ -333,7 +349,7 @@
{
Synchronized s(monitor);
- while(activeCounts[1] != 0) {
+ while (activeCounts[1] != 0) {
monitor.wait();
}
}
@@ -349,26 +365,28 @@
{
Synchronized s(monitor);
- while(activeCounts[2] != 0) {
+ while (activeCounts[2] != 0) {
monitor.wait();
}
}
- if(!(success = (threadManager->totalTaskCount() == 0))) {
+ if (!(success = (threadManager->totalTaskCount() == 0))) {
throw TException("Unexpected pending task count");
}
- } catch(TException& e) {
+ } catch (TException& e) {
std::cout << "ERROR: " << e.what() << std::endl;
}
std::cout << "\t\t\t" << (success ? "Success" : "Failure") << std::endl;
return success;
- }
+ }
};
const double ThreadManagerTests::TEST_TOLERANCE = .20;
-
-}}}} // apache::thrift::concurrency
+}
+}
+}
+} // apache::thrift::concurrency
using namespace apache::thrift::concurrency::test;
diff --git a/lib/cpp/test/concurrency/TimerManagerTests.h b/lib/cpp/test/concurrency/TimerManagerTests.h
index 62eb4f4..dda16ed 100644
--- a/lib/cpp/test/concurrency/TimerManagerTests.h
+++ b/lib/cpp/test/concurrency/TimerManagerTests.h
@@ -25,7 +25,10 @@
#include <assert.h>
#include <iostream>
-namespace apache { namespace thrift { namespace concurrency { namespace test {
+namespace apache {
+namespace thrift {
+namespace concurrency {
+namespace test {
using namespace apache::thrift::concurrency;
@@ -33,16 +36,15 @@
static const double TEST_TOLERANCE;
- public:
- class Task: public Runnable {
- public:
-
- Task(Monitor& monitor, int64_t timeout) :
- _timeout(timeout),
- _startTime(Util::currentTime()),
- _monitor(monitor),
- _success(false),
- _done(false) {}
+public:
+ class Task : public Runnable {
+ public:
+ Task(Monitor& monitor, int64_t timeout)
+ : _timeout(timeout),
+ _startTime(Util::currentTime()),
+ _monitor(monitor),
+ _success(false),
+ _done(false) {}
~Task() { std::cerr << this << std::endl; }
@@ -54,20 +56,20 @@
int64_t delta = _endTime - _startTime;
-
- delta = delta > _timeout ? delta - _timeout : _timeout - delta;
+ delta = delta > _timeout ? delta - _timeout : _timeout - delta;
float error = delta / _timeout;
- if(error < TEST_TOLERANCE) {
+ if (error < TEST_TOLERANCE) {
_success = true;
}
_done = true;
- std::cout << "\t\t\tTimerManagerTests::Task[" << this << "] done" << std::endl; //debug
+ std::cout << "\t\t\tTimerManagerTests::Task[" << this << "] done" << std::endl; // debug
- {Synchronized s(_monitor);
+ {
+ Synchronized s(_monitor);
_monitor.notifyAll();
}
}
@@ -86,9 +88,10 @@
* properly clean up itself and the remaining orphaned timeout task when the
* manager goes out of scope and its destructor is called.
*/
- bool test00(int64_t timeout=1000LL) {
+ bool test00(int64_t timeout = 1000LL) {
- shared_ptr<TimerManagerTests::Task> orphanTask = shared_ptr<TimerManagerTests::Task>(new TimerManagerTests::Task(_monitor, 10 * timeout));
+ shared_ptr<TimerManagerTests::Task> orphanTask
+ = shared_ptr<TimerManagerTests::Task>(new TimerManagerTests::Task(_monitor, 10 * timeout));
{
@@ -113,12 +116,13 @@
// Wait for 1 second in order to give timerManager a chance to start sleeping in response
// to adding orphanTask. We need to do this so we can verify that adding the second task
// kicks the dispatcher out of the current wait and starts the new 1 second wait.
- _monitor.wait (1000);
- assert (0 == "ERROR: This wait should time out. TimerManager dispatcher may have a problem.");
- } catch (TimedOutException &ex) {
+ _monitor.wait(1000);
+ assert(
+ 0 == "ERROR: This wait should time out. TimerManager dispatcher may have a problem.");
+ } catch (TimedOutException& ex) {
}
- task.reset (new TimerManagerTests::Task(_monitor, timeout));
+ task.reset(new TimerManagerTests::Task(_monitor, timeout));
timerManager.add(task, timeout);
@@ -127,7 +131,6 @@
assert(task->_done);
-
std::cout << "\t\t\t" << (task->_success ? "Success" : "Failure") << "!" << std::endl;
}
@@ -144,5 +147,7 @@
};
const double TimerManagerTests::TEST_TOLERANCE = .20;
-
-}}}} // apache::thrift::concurrency
+}
+}
+}
+} // apache::thrift::concurrency