int ProtocolMethod::UpdateFeedRecord(unsigned int userID, char *order, int result)
{
	char buf[MAX_BUFFER_SIZE] = {0};
	switch(result) {
		case 0:
			{
				DEBUG_MSG("userID: %d, order: %s, Feed result: Ok!", userID, order);
				snprintf(buf, MAX_BUFFER_SIZE, "update ca_recharge_record set state = 2, feed_result = 0 where h_userid = %d and feed_result = 200 and orderid = \'%s\'", userID, order);
				
				{
					MutexLockGuard(sql_->get_lock());
					sql_->Excute(buf);
				}
			}
			break;
		default:
			{
				ERROR_LOG(gs_id_.c_str(), "userID : %d, order : %s, Feed result: Error (%d) ! \n", userID, order, result);

				snprintf(buf, MAX_BUFFER_SIZE, "update ca_recharge_record set state = 1, feed_result = 201 where h_userid = %d and orderid = \'%s\'", userID, order);
				{
					MutexLockGuard(sql_->get_lock());
					sql_->Excute(buf);
				}
			}
			break;
	}
	return 0;
}
int ProtocolMethod::UpdateGSLoad(int num)
{
	char buf[MAX_BUFFER_SIZE] = {0};
	int state;
	switch(num) {
		case 0 ... 299:
			state = 1;
			break;
		case 300 ... 799:
			state = 2;
			break;
		default:
			state = 3;
			break;
	}

	snprintf(buf, MAX_BUFFER_SIZE, "update ca_gs set state = %d where upper(gsid) = upper('%s') and auto_update = 1", state, gs_id_.c_str());

	{
		MutexLockGuard(sql_->get_lock());
		if(sql_->Excute(buf)) {
			DEBUG_MSG("[%s] Online number = %d", gs_id_.c_str(), num);
		} else {
			ERROR_LOG(gs_id_.c_str(), "Sql exec error: %s, msg: %s", buf, sql_->GetErrorMsg().c_str());
		}
	}

	return 0;
}
Exemple #3
0
bool LockedQueue<T>::next(T& item)
{
    MutexLockGuard(_mutex);
    if (_queue.empty())
      return false;

    item = _queue.top();
    _queue.pop();
    return true;
}
Exemple #4
0
void LockedQueue<T>::add(const T& item)
{
    MutexLockGuard(_mutex);
    _queue.push_back(item);
}
Exemple #5
0
bool LockedQueue<T>::empty()
{
    MutexLockGuard(_mutex);
    return _queue.empty();
}