THRIFT-2729: C++ - .clang-format created and applied
Client: C++
Patch: Konrad Grochowski
make style command added
diff --git a/lib/cpp/test/processor/Handlers.h b/lib/cpp/test/processor/Handlers.h
index 75f4349..d894107 100644
--- a/lib/cpp/test/processor/Handlers.h
+++ b/lib/cpp/test/processor/Handlers.h
@@ -23,15 +23,14 @@
#include "gen-cpp/ParentService.h"
#include "gen-cpp/ChildService.h"
-namespace apache { namespace thrift { namespace test {
+namespace apache {
+namespace thrift {
+namespace test {
class ParentHandler : virtual public ParentServiceIf {
- public:
- ParentHandler(const boost::shared_ptr<EventLog>& log) :
- triggerMonitor(&mutex_),
- generation_(0),
- wait_(false),
- log_(log) { }
+public:
+ ParentHandler(const boost::shared_ptr<EventLog>& log)
+ : triggerMonitor(&mutex_), generation_(0), wait_(false), log_(log) {}
int32_t incrementGeneration() {
concurrency::Guard g(mutex_);
@@ -116,7 +115,7 @@
triggerMonitor.notifyAll();
}
- protected:
+protected:
/**
* blockUntilTriggered() won't return until triggerPendingCalls() is invoked
* in another thread.
@@ -141,10 +140,8 @@
};
class ChildHandler : public ParentHandler, virtual public ChildServiceIf {
- public:
- ChildHandler(const boost::shared_ptr<EventLog>& log) :
- ParentHandler(log),
- value_(0) {}
+public:
+ ChildHandler(const boost::shared_ptr<EventLog>& log) : ParentHandler(log), value_(0) {}
int32_t setValue(int32_t value) {
concurrency::Guard g(mutex_);
@@ -162,18 +159,16 @@
return value_;
}
- protected:
+protected:
int32_t value_;
};
struct ConnContext {
- public:
+public:
ConnContext(boost::shared_ptr<protocol::TProtocol> in,
boost::shared_ptr<protocol::TProtocol> out,
- uint32_t id) :
- input(in),
- output(out),
- id(id) {}
+ uint32_t id)
+ : input(in), output(out), id(id) {}
boost::shared_ptr<protocol::TProtocol> input;
boost::shared_ptr<protocol::TProtocol> output;
@@ -181,22 +176,18 @@
};
struct CallContext {
- public:
- CallContext(ConnContext *context, uint32_t id, const std::string& name) :
- connContext(context),
- name(name),
- id(id) {}
+public:
+ CallContext(ConnContext* context, uint32_t id, const std::string& name)
+ : connContext(context), name(name), id(id) {}
- ConnContext *connContext;
+ ConnContext* connContext;
std::string name;
uint32_t id;
};
class ServerEventHandler : public server::TServerEventHandler {
- public:
- ServerEventHandler(const boost::shared_ptr<EventLog>& log) :
- nextId_(1),
- log_(log) {}
+public:
+ ServerEventHandler(const boost::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {}
virtual void preServe() {}
@@ -209,8 +200,8 @@
}
virtual void deleteContext(void* serverContext,
- boost::shared_ptr<protocol::TProtocol>input,
- boost::shared_ptr<protocol::TProtocol>output) {
+ boost::shared_ptr<protocol::TProtocol> input,
+ boost::shared_ptr<protocol::TProtocol> output) {
ConnContext* context = reinterpret_cast<ConnContext*>(serverContext);
if (input != context->input) {
@@ -225,22 +216,21 @@
delete context;
}
- virtual void processContext(
- void* serverContext,
- boost::shared_ptr<transport::TTransport> transport) {
- // TODO: We currently don't test the behavior of the processContext()
- // calls. The various server implementations call processContext() at
- // slightly different times, and it is too annoying to try and account for
- // their various differences.
- //
- // TThreadedServer, TThreadPoolServer, and TSimpleServer usually wait until
- // they see the first byte of a request before calling processContext().
- // However, they don't wait for the first byte of the very first request,
- // and instead immediately call processContext() before any data is
- // received.
- //
- // TNonblockingServer always waits until receiving the full request before
- // calling processContext().
+ virtual void processContext(void* serverContext,
+ boost::shared_ptr<transport::TTransport> transport) {
+// TODO: We currently don't test the behavior of the processContext()
+// calls. The various server implementations call processContext() at
+// slightly different times, and it is too annoying to try and account for
+// their various differences.
+//
+// TThreadedServer, TThreadPoolServer, and TSimpleServer usually wait until
+// they see the first byte of a request before calling processContext().
+// However, they don't wait for the first byte of the very first request,
+// and instead immediately call processContext() before any data is
+// received.
+//
+// TNonblockingServer always waits until receiving the full request before
+// calling processContext().
#if 0
ConnContext* context = reinterpret_cast<ConnContext*>(serverContext);
log_->append(EventLog::ET_PROCESS, context->id, 0);
@@ -250,16 +240,14 @@
#endif
}
- protected:
+protected:
uint32_t nextId_;
boost::shared_ptr<EventLog> log_;
};
class ProcessorEventHandler : public TProcessorEventHandler {
- public:
- ProcessorEventHandler(const boost::shared_ptr<EventLog>& log) :
- nextId_(1),
- log_(log) {}
+public:
+ ProcessorEventHandler(const boost::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {}
void* getContext(const char* fnName, void* serverContext) {
ConnContext* connContext = reinterpret_cast<ConnContext*>(serverContext);
@@ -267,71 +255,65 @@
CallContext* context = new CallContext(connContext, nextId_, fnName);
++nextId_;
- log_->append(EventLog::ET_CALL_STARTED, connContext->id, context->id,
- fnName);
+ log_->append(EventLog::ET_CALL_STARTED, connContext->id, context->id, fnName);
return context;
}
void freeContext(void* ctx, const char* fnName) {
CallContext* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
- log_->append(EventLog::ET_CALL_FINISHED, context->connContext->id,
- context->id, fnName);
+ log_->append(EventLog::ET_CALL_FINISHED, context->connContext->id, context->id, fnName);
delete context;
}
void preRead(void* ctx, const char* fnName) {
CallContext* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
- log_->append(EventLog::ET_PRE_READ, context->connContext->id, context->id,
- fnName);
+ log_->append(EventLog::ET_PRE_READ, context->connContext->id, context->id, fnName);
}
void postRead(void* ctx, const char* fnName, uint32_t bytes) {
THRIFT_UNUSED_VARIABLE(bytes);
CallContext* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
- log_->append(EventLog::ET_POST_READ, context->connContext->id, context->id,
- fnName);
+ log_->append(EventLog::ET_POST_READ, context->connContext->id, context->id, fnName);
}
void preWrite(void* ctx, const char* fnName) {
CallContext* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
- log_->append(EventLog::ET_PRE_WRITE, context->connContext->id, context->id,
- fnName);
+ log_->append(EventLog::ET_PRE_WRITE, context->connContext->id, context->id, fnName);
}
void postWrite(void* ctx, const char* fnName, uint32_t bytes) {
THRIFT_UNUSED_VARIABLE(bytes);
CallContext* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
- log_->append(EventLog::ET_POST_WRITE, context->connContext->id,
- context->id, fnName);
+ log_->append(EventLog::ET_POST_WRITE, context->connContext->id, context->id, fnName);
}
void asyncComplete(void* ctx, const char* fnName) {
CallContext* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
- log_->append(EventLog::ET_ASYNC_COMPLETE, context->connContext->id,
- context->id, fnName);
+ log_->append(EventLog::ET_ASYNC_COMPLETE, context->connContext->id, context->id, fnName);
}
void handlerError(void* ctx, const char* fnName) {
CallContext* context = reinterpret_cast<CallContext*>(ctx);
checkName(context, fnName);
- log_->append(EventLog::ET_HANDLER_ERROR, context->connContext->id,
- context->id, fnName);
+ log_->append(EventLog::ET_HANDLER_ERROR, context->connContext->id, context->id, fnName);
}
- protected:
+protected:
void checkName(const CallContext* context, const char* fnName) {
// Note: we can't use BOOST_CHECK_EQUAL here, since the handler runs in a
// different thread from the test functions. Just abort if the names are
// different
if (context->name != fnName) {
- fprintf(stderr, "call context name mismatch: \"%s\" != \"%s\"\n",
- context->name.c_str(), fnName);
+ fprintf(stderr,
+ "call context name mismatch: \"%s\" != \"%s\"\n",
+ context->name.c_str(),
+ fnName);
fflush(stderr);
abort();
}
@@ -340,7 +322,8 @@
uint32_t nextId_;
boost::shared_ptr<EventLog> log_;
};
-
-}}} // apache::thrift::test
+}
+}
+} // apache::thrift::test
#endif // _THRIFT_PROCESSOR_TEST_HANDLERS_H_