本文整理汇总了C++中dmtcp::string::length方法的典型用法代码示例。如果您正苦于以下问题:C++ string::length方法的具体用法?C++ string::length怎么用?C++ string::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dmtcp::string
的用法示例。
在下文中一共展示了string::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JASSERT
static dmtcp::string _resolveSymlink(dmtcp::string path)
{
dmtcp::string device = jalib::Filesystem::ResolveSymlink(path);
if (dmtcp_real_to_virtual_pid && path.length() > 0 &&
dmtcp::Util::strStartsWith(device, "/proc/")) {
int index = 6;
char *rest;
char newpath[128];
JASSERT(device.length() < sizeof newpath);
pid_t realPid = strtol(&path[index], &rest, 0);
if (realPid > 0 && *rest == '/') {
pid_t virtualPid = dmtcp_real_to_virtual_pid(realPid);
sprintf(newpath, "/proc/%d%s", virtualPid, rest);
device = newpath;
}
}
return device;
}
示例2: UniquePid
void dmtcp::DmtcpCoordinatorAPI::sendCoordinatorHandshake (
const dmtcp::string& progname,
UniquePid compGroup /*= UniquePid()*/,
int np /*= -1*/,
DmtcpMessageType msgType /*= DMT_HELLO_COORDINATOR*/)
{
JTRACE("sending coordinator handshake")(UniquePid::ThisProcess());
dmtcp::string hostname = jalib::Filesystem::GetCurrentHostname();
const char *prefixPathEnv = getenv(ENV_VAR_PREFIX_PATH);
dmtcp::string prefixDir;
DmtcpMessage hello_local;
hello_local.type = msgType;
hello_local.params[0] = np;
hello_local.compGroup = compGroup;
hello_local.restorePort = theRestorePort;
if (getenv(ENV_VAR_VIRTUAL_PID) == NULL) {
hello_local.virtualPid = -1;
} else {
hello_local.virtualPid = (pid_t) atoi(getenv(ENV_VAR_VIRTUAL_PID));
}
const char* interval = getenv ( ENV_VAR_CKPT_INTR );
/* DmtcpMessage constructor default:
* hello_local.theCheckpointInterval: DMTCPMESSAGE_SAME_CKPT_INTERVAL
*/
if ( interval != NULL )
hello_local.theCheckpointInterval = jalib::StringToInt ( interval );
// Tell the coordinator the ckpt interval only once. It can change later.
_dmtcp_unsetenv ( ENV_VAR_CKPT_INTR );
hello_local.extraBytes = hostname.length() + 1 + progname.length() + 1;
if (prefixPathEnv != NULL) {
/* If --prefix was defined then this process is either running on the local
* node (the home of first process in the comptation) or a remote node.
*
* If the process is running on the local node, the prefix-path-env may be
* different from the prefix-dir of this binary, in which case, we want to
* send the prefix-path of this binary to the coordinator and the
* coordinator will save it as the local-prefix.
*
* However, if this is running on a remote node, the prefix-path-env would
* be the same as the prefix-path of this binary and we should send the
* prefix-path-env to the coordinator and the coordinator will note this as
* the remote-prefix.
*/
dmtcp::string utilDirPrefix =
jalib::Filesystem::DirName(getenv(ENV_VAR_UTILITY_DIR));
if (utilDirPrefix == jalib::Filesystem::ResolveSymlink(prefixPathEnv)) {
prefixDir = prefixPathEnv;
} else {
prefixDir = utilDirPrefix;
}
hello_local.extraBytes += prefixDir.length() + 1;
}
_coordinatorSocket << hello_local;
_coordinatorSocket.writeAll( hostname.c_str(),hostname.length()+1);
_coordinatorSocket.writeAll( progname.c_str(),progname.length()+1);
if (!prefixDir.empty()) {
_coordinatorSocket.writeAll(prefixDir.c_str(), prefixDir.length()+1);
}
}