}
}
}
- indent_down();
- indent(out) << "} " << endl;
+ scope_down(out);
}
out <<
// Check for field STOP marker
out <<
- indent() << "if (ftype == facebook::thrift::protocol::T_STOP) { " << endl <<
+ indent() << "if (ftype == facebook::thrift::protocol::T_STOP) {" << endl <<
indent() << " break;" << endl <<
indent() << "}" << endl;
}
f_header_ <<
"class " << service_name_ << "If" << extends << " {" << endl <<
- " public: " << endl;
+ " public:" << endl;
indent_up();
f_header_ <<
indent() << "virtual ~" << service_name_ << "If() {}" << endl;
}
indent_down();
f_header_ <<
- "}; " << endl << endl;
+ "};" << endl << endl;
}
/**
}
f_header_ <<
"class " << service_name_ << "Null : virtual public " << service_name_ << "If" << extends << " {" << endl <<
- " public: " << endl;
+ " public:" << endl;
indent_up();
f_header_ <<
indent() << "virtual ~" << service_name_ << "Null() {}" << endl;
}
indent_down();
f_header_ <<
- "}; " << endl << endl;
+ "};" << endl << endl;
}
"class " << service_name_ << "Multiface : " <<
"virtual public " << service_name_ << "If" <<
extends_multiface << " {" << endl <<
- " public: " << endl;
+ " public:" << endl;
indent_up();
f_header_ <<
indent() << service_name_ << "Multiface(" << list_type << "& ifaces) : ifaces_(ifaces) {" << endl;
f_header_ <<
indent() << list_type << " ifaces_;" << endl <<
indent() << service_name_ << "Multiface() {}" << endl <<
- indent() << "void add(boost::shared_ptr<" << service_name_ << "If> iface) { " << endl;
+ indent() << "void add(boost::shared_ptr<" << service_name_ << "If> iface) {" << endl;
if (!extends.empty()) {
f_header_ <<
indent() << " " << extends << "Multiface::add(iface);" << endl;
indent_up();
f_header_ <<
- indent() << service_name_ << "Client(boost::shared_ptr<facebook::thrift::protocol::TProtocol> prot) : " << endl;
+ indent() << service_name_ << "Client(boost::shared_ptr<facebook::thrift::protocol::TProtocol> prot) :" << endl;
if (extends.empty()) {
f_header_ <<
indent() << " piprot_(prot)," << endl <<
}
f_header_ <<
- indent() << service_name_ << "Client(boost::shared_ptr<facebook::thrift::protocol::TProtocol> iprot, boost::shared_ptr<facebook::thrift::protocol::TProtocol> oprot) : " << endl;
+ indent() << service_name_ << "Client(boost::shared_ptr<facebook::thrift::protocol::TProtocol> iprot, boost::shared_ptr<facebook::thrift::protocol::TProtocol> oprot) :" << endl;
if (extends.empty()) {
f_header_ <<
indent() << " piprot_(iprot)," << endl <<
indent_down();
f_header_ <<
- " public: " << endl <<
+ " public:" << endl <<
indent() << service_name_ << "Processor(boost::shared_ptr<" << service_name_ << "If> iface) :" << endl;
if (extends.empty()) {
f_header_ <<
return "";
}
string result = "";
+ string separator = "";
string::size_type loc;
while ((loc = ns.find(".")) != string::npos) {
+ result += separator;
result += "namespace ";
result += ns.substr(0, loc);
- result += " { ";
+ result += " {";
+ separator = " ";
ns = ns.substr(loc+1);
}
if (ns.size() > 0) {
- result += "namespace " + ns + " { ";
+ result += separator + "namespace " + ns + " {";
}
return result;
}
libtool \
ltmain.sh \
Makefile.in \
-missing
+missing \
+config.hin~ \
+stamp-h1
RWGuard(const ReadWriteMutex& value, bool write = 0) : rw_mutex_(value) {
if (write) {
rw_mutex_.acquireWrite();
- } else {
+ } else {
rw_mutex_.acquireRead();
- }
+ }
}
~RWGuard() {
rw_mutex_.release();
Synchronized s(manager_->monitor_);
active = manager_->workerCount_ < manager_->workerMaxCount_;
if (active) {
- manager_->workerCount_++;
- notifyManager = manager_->workerCount_ == manager_->workerMaxCount_;
+ manager_->workerCount_++;
+ notifyManager = manager_->workerCount_ == manager_->workerMaxCount_;
}
}
*/
{
Synchronized s(manager_->monitor_);
- active = isActive();
+ active = isActive();
- while (active && manager_->tasks_.empty()) {
+ while (active && manager_->tasks_.empty()) {
manager_->idleCount_++;
idle_ = true;
manager_->monitor_.wait();
active = isActive();
idle_ = false;
manager_->idleCount_--;
- }
+ }
- if (active) {
+ if (active) {
if (!manager_->tasks_.empty()) {
task = manager_->tasks_.front();
manager_->tasks_.pop();
if (task->state_ == ThreadManager::Task::WAITING) {
task->state_ = ThreadManager::Task::EXECUTING;
- }
+ }
/* If we have a pending task max and we just dropped below it, wakeup any
thread that might be blocked on add. */
manager_->tasks_.size() == manager_->pendingTaskCountMax_ - 1) {
manager_->workerMonitor_.notify();
}
- }
- } else {
- idle_ = true;
- manager_->workerCount_--;
+ }
+ } else {
+ idle_ = true;
+ manager_->workerCount_--;
notifyManager = (manager_->workerCount_ == manager_->workerMaxCount_);
- }
+ }
}
if (task != NULL) {
- if (task->state_ == ThreadManager::Task::EXECUTING) {
- try {
+ if (task->state_ == ThreadManager::Task::EXECUTING) {
+ try {
task->run();
} catch(...) {
// XXX need to log this
- }
- }
+ }
+ }
}
}
if (idleCount_ < value) {
for (size_t ix = 0; ix < idleCount_; ix++) {
- monitor_.notify();
+ monitor_.notify();
}
} else {
monitor_.notifyAll();
{
Synchronized s(manager_->monitor_);
if (manager_->state_ == TimerManager::STARTING) {
- manager_->state_ = TimerManager::STARTED;
- manager_->monitor_.notifyAll();
+ manager_->state_ = TimerManager::STARTED;
+ manager_->monitor_.notifyAll();
}
}
std::set<shared_ptr<TimerManager::Task> > expiredTasks;
{
Synchronized s(manager_->monitor_);
- task_iterator expiredTaskEnd;
- int64_t now = Util::currentTime();
- while (manager_->state_ == TimerManager::STARTED &&
+ task_iterator expiredTaskEnd;
+ int64_t now = Util::currentTime();
+ while (manager_->state_ == TimerManager::STARTED &&
(expiredTaskEnd = manager_->taskMap_.upper_bound(now)) == manager_->taskMap_.begin()) {
- int64_t timeout = 0LL;
- if (!manager_->taskMap_.empty()) {
+ int64_t timeout = 0LL;
+ if (!manager_->taskMap_.empty()) {
timeout = manager_->taskMap_.begin()->first - now;
- }
+ }
assert((timeout != 0 && manager_->taskCount_ > 0) || (timeout == 0 && manager_->taskCount_ == 0));
try {
manager_->monitor_.wait(timeout);
} catch (TimedOutException &e) {}
- now = Util::currentTime();
- }
-
- if (manager_->state_ == TimerManager::STARTED) {
+ now = Util::currentTime();
+ }
+
+ if (manager_->state_ == TimerManager::STARTED) {
for (task_iterator ix = manager_->taskMap_.begin(); ix != expiredTaskEnd; ix++) {
- shared_ptr<TimerManager::Task> task = ix->second;
+ shared_ptr<TimerManager::Task> task = ix->second;
expiredTasks.insert(task);
- if (task->state_ == TimerManager::Task::WAITING) {
- task->state_ = TimerManager::Task::EXECUTING;
- }
+ if (task->state_ == TimerManager::Task::WAITING) {
+ task->state_ = TimerManager::Task::EXECUTING;
+ }
manager_->taskCount_--;
- }
+ }
manager_->taskMap_.erase(manager_->taskMap_.begin(), expiredTaskEnd);
- }
+ }
}
for (std::set<shared_ptr<Task> >::iterator ix = expiredTasks.begin(); ix != expiredTasks.end(); ix++) {
{
Synchronized s(manager_->monitor_);
if (manager_->state_ == TimerManager::STOPPING) {
- manager_->state_ = TimerManager::STOPPED;
- manager_->monitor_.notify();
+ manager_->state_ = TimerManager::STOPPED;
+ manager_->monitor_.notify();
}
}
return;
for (size_t workerCount = minWorkerCount; workerCount < maxWorkerCount; workerCount*= 2) {
- size_t taskCount = workerCount * tasksPerWorker;
+ 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;
+ ThreadManagerTests threadManagerTests;
- threadManagerTests.loadTest(taskCount, delay, workerCount);
+ threadManagerTests.loadTest(taskCount, delay, workerCount);
}
}
}
void run() {
{
Synchronized s(_monitor);
- if (_state == SynchStartTask::STARTING) {
- _state = SynchStartTask::STARTED;
- _monitor.notify();
- }
+ if (_state == SynchStartTask::STARTING) {
+ _state = SynchStartTask::STARTED;
+ _monitor.notify();
+ }
}
{
Synchronized s(_monitor);
while (_state == SynchStartTask::STARTED) {
- _monitor.wait();
- }
+ _monitor.wait();
+ }
- if (_state == SynchStartTask::STOPPING) {
+ if (_state == SynchStartTask::STOPPING) {
_state = SynchStartTask::STOPPED;
_monitor.notifyAll();
- }
+ }
}
}
{
Synchronized s(monitor);
while (state == SynchStartTask::STARTING) {
- monitor.wait();
+ monitor.wait();
}
}
if (state == SynchStartTask::STARTED) {
- state = SynchStartTask::STOPPING;
+ state = SynchStartTask::STOPPING;
- monitor.notify();
+ monitor.notify();
}
while (state == SynchStartTask::STOPPING) {
- monitor.wait();
+ monitor.wait();
}
}
{
Synchronized s(_monitor);
- // std::cout << "Thread " << _count << " completed " << std::endl;
+ // std::cout << "Thread " << _count << " completed " << std::endl;
- _count--;
+ _count--;
- if (_count == 0) {
+ if (_count == 0) {
- _monitor.notify();
- }
+ _monitor.notify();
+ }
}
}
for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
- threadManager->add(*ix);
+ threadManager->add(*ix);
}
{
while(activeCount > 0) {
- monitor.wait();
+ monitor.wait();
}
}
assert(delta > 0);
if (task->_startTime < firstTime) {
- firstTime = task->_startTime;
+ firstTime = task->_startTime;
}
if (task->_endTime > lastTime) {
- lastTime = task->_endTime;
+ lastTime = task->_endTime;
}
if (delta < minTime) {
- minTime = delta;
+ minTime = delta;
}
if (delta > maxTime) {
- maxTime = delta;
+ maxTime = delta;
}
averageTime+= delta;
}
for (std::set<shared_ptr<ThreadManagerTests::BlockTask> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
- threadManager->add(*ix);
+ threadManager->add(*ix);
}
if(!(success = (threadManager->totalTaskCount() == pendingTaskMaxCount + workerCount))) {
float error = delta / _timeout;
if(error < ERROR) {
- _success = true;
+ _success = true;
}
_done = true;
std::cout << "\t\t\tTimerManagerTests::Task[" << this << "] done" << std::endl; //debug
{Synchronized s(_monitor);
- _monitor.notifyAll();
+ _monitor.notifyAll();
}
}
{
Synchronized s(_monitor);
- timerManager.add(orphanTask, 10 * timeout);
+ timerManager.add(orphanTask, 10 * timeout);
- timerManager.add(task, timeout);
+ timerManager.add(task, timeout);
- _monitor.wait();
+ _monitor.wait();
}
assert(task->_done);
*/
uint32_t TBinaryProtocol::readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid) {
+ TMessageType& messageType,
+ int32_t& seqid) {
uint32_t result = 0;
int32_t sz;
result += readI32(sz);
uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid);
+ TMessageType& messageType,
+ int32_t& seqid);
uint32_t readMessageEnd();
uint32_t readStructEnd();
uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId);
+ TType& fieldType,
+ int16_t& fieldId);
uint32_t readFieldEnd();
uint32_t readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size);
+ TType& valType,
+ uint32_t& size);
uint32_t readMapEnd();
uint32_t readListEnd();
uint32_t readSetBegin(TType& elemType,
- uint32_t& size);
+ uint32_t& size);
uint32_t readSetEnd();
*/
uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid) {
+ TMessageType& messageType,
+ int32_t& seqid) {
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
subclass_ + " does not support reading (yet).");
}
}
uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId) {
+ TType& fieldType,
+ int16_t& fieldId) {
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
subclass_ + " does not support reading (yet).");
}
}
uint32_t readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size) {
+ TType& valType,
+ uint32_t& size) {
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
subclass_ + " does not support reading (yet).");
}
}
uint32_t readSetBegin(TType& elemType,
- uint32_t& size) {
+ uint32_t& size) {
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
subclass_ + " does not support reading (yet).");
}
virtual uint32_t writeStructEnd() = 0;
virtual uint32_t writeFieldBegin(const std::string& name,
- const TType fieldType,
- const int16_t fieldId) = 0;
+ const TType fieldType,
+ const int16_t fieldId) = 0;
virtual uint32_t writeFieldEnd() = 0;
virtual uint32_t writeFieldStop() = 0;
virtual uint32_t writeMapBegin(const TType keyType,
- const TType valType,
- const uint32_t size) = 0;
+ const TType valType,
+ const uint32_t size) = 0;
virtual uint32_t writeMapEnd() = 0;
virtual uint32_t writeListBegin(const TType elemType,
- const uint32_t size) = 0;
+ const uint32_t size) = 0;
virtual uint32_t writeListEnd() = 0;
virtual uint32_t writeSetBegin(const TType elemType,
- const uint32_t size) = 0;
+ const uint32_t size) = 0;
virtual uint32_t writeSetEnd() = 0;
*/
virtual uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid) = 0;
+ TMessageType& messageType,
+ int32_t& seqid) = 0;
virtual uint32_t readMessageEnd() = 0;
virtual uint32_t readStructEnd() = 0;
virtual uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId) = 0;
+ TType& fieldType,
+ int16_t& fieldId) = 0;
virtual uint32_t readFieldEnd() = 0;
virtual uint32_t readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size) = 0;
+ TType& valType,
+ uint32_t& size) = 0;
virtual uint32_t readMapEnd() = 0;
virtual uint32_t readListBegin(TType& elemType,
- uint32_t& size) = 0;
+ uint32_t& size) = 0;
virtual uint32_t readListEnd() = 0;
virtual uint32_t readSetBegin(TType& elemType,
- uint32_t& size) = 0;
+ uint32_t& size) = 0;
virtual uint32_t readSetEnd() = 0;