本文整理汇总了C++中Monitor::close方法的典型用法代码示例。如果您正苦于以下问题:C++ Monitor::close方法的具体用法?C++ Monitor::close怎么用?C++ Monitor::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monitor
的用法示例。
在下文中一共展示了Monitor::close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleClient
static void handleClient() {
OlySocket client(sock->acceptConnection());
int pid = fork();
if (pid < 0) {
// Error
logg.logError("Fork process failed. Please power cycle the target device if this error persists.");
handleException();
} else if (pid == 0) {
// Child
sock->closeServerSocket();
udpListener.close();
monitor.close();
annotateListener.close();
child = new Child(&client, numSessions + 1);
child->run();
delete child;
exit(0);
} else {
// Parent
client.closeSocket();
pthread_mutex_lock(&numSessions_mutex);
numSessions++;
pthread_mutex_unlock(&numSessions_mutex);
// Maximum number of connections is 2
int wait = 0;
while (numSessions > 1) {
// Throttle until one of the children exits before continuing to accept another socket connection
logg.logMessage("%d sessions active!", numSessions);
if (wait++ >= 10) { // Wait no more than 10 seconds
// Kill last created child
kill(pid, SIGALRM);
break;
}
sleep(1);
}
}
}