当前位置: 首页>>代码示例>>C++>>正文


C++ TimeStamp::microseconds方法代码示例

本文整理汇总了C++中TimeStamp::microseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeStamp::microseconds方法的具体用法?C++ TimeStamp::microseconds怎么用?C++ TimeStamp::microseconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeStamp的用法示例。


在下文中一共展示了TimeStamp::microseconds方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: diffTime

double diffTime(TimeStamp &previousTime, TimeStamp &currentTime) {
    double diffSeconds = currentTime.seconds() - previousTime.seconds();
    int32_t diffMicroseconds = currentTime.microseconds() - previousTime.microseconds();
    if (diffMicroseconds < 0) {
        --diffSeconds;
        diffMicroseconds += 1000000;
    }
    return (diffSeconds + (static_cast<double>(diffMicroseconds)/1000000));
}
开发者ID:derrick0714,项目名称:infer,代码行数:9,代码来源:sqlTime.cpp

示例2: getDisplayTime

std::string getDisplayTime(const TimeStamp timeStamp) {
    std::ostringstream timeString;
    if (timeStamp.seconds()) {
        timeString << getSQLTime(timeStamp.seconds()).getDateTime() << '.'
                   << std::setw(6) << std::setfill('0') << timeStamp.microseconds();
        return timeString.str();
    }
    return "Not seen";
}
开发者ID:derrick0714,项目名称:infer,代码行数:9,代码来源:sqlTime.cpp

示例3: getLastResolutionTime

bool NameResolution::getLastResolutionTime(TimeStamp &ret, const uint32_t &host, const uint32_t &resolvedIP, const TimeStamp &t, ims::name::NameResolutionSourceType sourceType) {
	// prepare the command
	cmdLen = 19; //
	uint16_t tmpCmdLen = htons(cmdLen);
	memcpy(buf, &tmpCmdLen, sizeof(uint16_t));
	buf[2] = 0; // type, NameResolution
	buf[3] = 7; // function, getLastResolutionTime
	if (sourceType == ims::name::NameResolutionSourceType::ANY) {
		buf[4] = 0;
	} else if (sourceType == ims::name::NameResolutionSourceType::DNS) {
		buf[4] = 1;
	}
	this -> ip = htonl(host);
	memcpy(buf + 5, &(this -> ip), sizeof(uint32_t)); // arg (host)
	this -> ip = htonl(resolvedIP);
	memcpy(buf + 9, &(this -> ip), sizeof(uint32_t)); // arg (resolvedIP)
	this -> ip = htonl(t.seconds());
	memcpy(buf + 13, &(this -> ip), sizeof(uint32_t)); // arg (seconds)
	this -> ip = htonl(t.microseconds());
	memcpy(buf + 17, &(this -> ip), sizeof(uint32_t)); // arg (microseconds)

	// issue the command
	if (socket_write(conn_fd, buf, cmdLen + 2, sockTimeout) != cmdLen + 2) {
		// something went wrong...reconnect, try one more time, then fail
		close(conn_fd);
		if (!establishConnection()) {
			return false;
		}
		if (socket_write(conn_fd, buf, cmdLen + 2, sockTimeout) != cmdLen + 2) {
			return false;
		}
	}
	// at this point, all is well, and command has been issued
	// read back the answer
	if (socket_read(conn_fd, (char *) &ret, sizeof(ret), sockTimeout) != sizeof(ret)) {
		// error
		return false;
	}
	ret.set(ntohl(ret.seconds()), ntohl(ret.microseconds()));

	return true;
}
开发者ID:,项目名称:,代码行数:42,代码来源:

示例4: load

bool NameResolution::load(const TimeStamp &begin, const TimeStamp &end, ims::name::NameResolutionSourceType sourceType) {
	// prepare the command
	cmdLen = 19; //
	uint16_t tmpCmdLen = htons(cmdLen);
	memcpy(buf, &tmpCmdLen, sizeof(uint16_t));
	buf[2] = 0; // type, NameResolution
	buf[3] = -2; // function, load
	if (sourceType == ims::name::NameResolutionSourceType::ANY) {
		buf[4] = 0;
	} else if (sourceType == ims::name::NameResolutionSourceType::DNS) {
		buf[4] = 1;
	}
	this -> ip = htonl(begin.seconds());
	memcpy(buf + 5, &(this -> ip), sizeof(uint32_t)); // arg (t)
	this -> ip = htonl(begin.microseconds());
	memcpy(buf + 9, &(this -> ip), sizeof(uint32_t)); // arg (t)
	this -> ip = htonl(end.seconds());
	memcpy(buf + 13, &(this -> ip), sizeof(uint32_t)); // arg (t)
	this -> ip = htonl(end.microseconds());
	memcpy(buf + 17, &(this -> ip), sizeof(uint32_t)); // arg (t)

	// issue the command
	if (socket_write(conn_fd, buf, cmdLen + 2, sockTimeout) != cmdLen + 2) {
		// something went wrong...reconnect, try one more time, then fail
		close(conn_fd);
		if (!establishConnection()) {
			return false;
		}
		if (socket_write(conn_fd, buf, cmdLen + 2, sockTimeout) != cmdLen + 2) {
			return false;
		}
	}

	if (socket_read(conn_fd, buf, 1, sockTimeout) != 1) {
		// error
		return false;
	}

	return true;
}
开发者ID:,项目名称:,代码行数:40,代码来源:

示例5: return

bool TimeStamp::operator>(const TimeStamp &right) const {
  if (_seconds != right.seconds()) {
    return (_seconds > right.seconds());
  }
  return (_microseconds > right.microseconds());
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例6: processNameResCmd


//.........这里部分代码省略.........
			 it != nameResBuffs.ips.end();
			 ++it)
		{
			tmpIP = htonl(*it);
			if ((ret = socket_write(fd, (char *) &tmpIP, 4, queryManConfig.sockTimeout)) == -1) {
				// Error
				cerr << "socket_write() returned -1." << endl;
				return -1;
			} else if (ret != 4) {
				cerr << "socket_write() timeout." << endl;
				return -1;
			}
		}
		break;
	  case 6: // hasHostResolvedIP
		if (len != 2 + 4 + 4 + 8) {
			return -1;
		}
		ch = (nameResMan.hasHostResolvedIP(ntohl(*(uint32_t *) (buf + 2)), ntohl(*(uint32_t *) (buf + 6)), TimeStamp(ntohl(*(uint32_t *) (buf + 10)), ntohl(*(uint32_t *) (buf + 14))), stype))?1:0;
		if ((ret = socket_write(fd, (char *) &ch, 1, queryManConfig.sockTimeout)) == -1) {
			// Error
			cerr << "socket_write() returned -1." << endl;
			return -1;
		} else if (ret != 1) {
			cerr << "socket_write() timeout." << endl;
			return -1;
		}
		break;
	  case 7: // getLastResolutionTime
		if (len != 2 + 4 + 4 + 8) {
			return -1;
		}
		t = nameResMan.getLastResolutionTime(ntohl(*(uint32_t *) (buf + 2)), ntohl(*(uint32_t *) (buf + 6)), TimeStamp(ntohl(*(uint32_t *) (buf + 10)), ntohl(*(uint32_t *) (buf + 14))), stype);
		t.set(ntohl(t.seconds()), ntohl(t.microseconds()));
		if ((ret = socket_write(fd, (char *) &t, sizeof(t), queryManConfig.sockTimeout)) == -1) {
			// Error
			cerr << "socket_write() returned -1." << endl;
			return -1;
		} else if (ret != sizeof(t)) {
			cerr << "socket_write() timeout." << endl;
			return -1;
		}
		break;
	  case -1: // clear
		if (len != 2) {
			// return error
			return -1;
		}
		nameResMan.clear(stype);
		ch = 0;
		if ((ret = socket_write(fd, (char *) &ch, 1, queryManConfig.sockTimeout)) == -1) {
			// Error
			cerr << "socket_write() returned -1." << endl;
			return -1;
		} else if (ret != 1) {
			cerr << "socket_write() timeout." << endl;
			return -1;
		}
		break;
	  case -2: // load
		// load specific name resolution data
		if (len != 18) {
			// return error
			return -1;
		}
		begin.set(ntohl(*reinterpret_cast<uint32_t*>(buf + 2)), ntohl(*reinterpret_cast<uint32_t*>(buf + 6)));
开发者ID:derrick0714,项目名称:infer,代码行数:67,代码来源:query_manager.cpp


注:本文中的TimeStamp::microseconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。