本文整理汇总了C++中PROC_MAP::end方法的典型用法代码示例。如果您正苦于以下问题:C++ PROC_MAP::end方法的具体用法?C++ PROC_MAP::end怎么用?C++ PROC_MAP::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PROC_MAP
的用法示例。
在下文中一共展示了PROC_MAP::end方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find_children
void find_children(PROC_MAP& pm) {
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); i++) {
int parentid = i->second.parentid;
PROC_MAP::iterator j = pm.find(parentid);
if (j == pm.end()) continue; // should never happen
j->second.children.push_back(i->first);
}
}
示例2: procinfo_app
// Fill in the given PROCINFO (initially zero except for id)
// with totals from that process and all its descendants.
// Set PROCINFO.is_boinc_app for all of them.
//
void procinfo_app(
PROCINFO& pi, vector<int>* other_pids, PROC_MAP& pm, char* graphics_exec_file
) {
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); i++) {
PROCINFO& p = i->second;
if (p.id == pi.id
|| (other_pids && in_vector(p.id, *other_pids))
) {
pi.kernel_time += p.kernel_time;
pi.user_time += p.user_time;
pi.swap_size += p.swap_size;
pi.working_set_size += p.working_set_size;
p.is_boinc_app = true;
p.scanned = true;
// look for child processes
//
add_child_totals(pi, pm, i);
return;
}
if (graphics_exec_file && !strcmp(p.command, graphics_exec_file)) {
p.is_boinc_app = true;
}
}
}
示例3: add_child_totals
// Scan the process table adding in CPU time and mem usage.
//
void add_child_totals(PROCINFO& pi, PROC_MAP& pm, PROC_MAP::iterator i) {
PROCINFO parent = i->second;
for (unsigned int j=0; j<parent.children.size(); j++) {
int child_pid = parent.children[j];
PROC_MAP::iterator i2 = pm.find(child_pid);
if (i2 == pm.end()) continue;
PROCINFO& p = i2->second;
if (p.scanned) {
return; // cycle in graph - shouldn't happen
}
pi.kernel_time += p.kernel_time;
pi.user_time += p.user_time;
p.scanned = true;
// only count process with most swap and memory
if (p.swap_size > pi.swap_size) {
pi.swap_size = p.swap_size;
}
if (p.working_set_size > pi.working_set_size) {
pi.working_set_size = p.working_set_size;
}
p.is_boinc_app = true;
add_child_totals(pi, pm, i2); // recursion - woo hoo!
}
}
示例4: get_descendants_aux
static void get_descendants_aux(PROC_MAP& pm, int pid, vector<int>& pids) {
PROC_MAP::iterator i = pm.find(pid);
if (i == pm.end()) return;
for (unsigned int j=0; j<i->second.children.size(); j++) {
int child_pid = i->second.children[j];
pids.push_back(child_pid);
get_descendants_aux(pm, child_pid, pids);
}
}
示例5: IsAnotherInstanceRunning
///
/// Determines if another instance of BOINC Manager is running.
///
/// @return
/// true if another instance of BOINC Manager is running, otherwise false.
///
/// Note: will always return false on Win95, Win98, WinME
///
int CBOINCGUIApp::IsAnotherInstanceRunning() {
PROC_MAP pm;
int retval;
char myName[256];
int otherInstanceID = 0;
int myPid;
// Look for BOINC Manager in list of all running processes
retval = procinfo_setup(pm);
if (retval) return false; // Should never happen
#ifdef _WIN32
myPid = (int)GetCurrentProcessId();
#else
myPid = getpid();
#endif
// Get the name of this Application
myName[0] = 0;
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); i++) {
PROCINFO& procinfo = i->second;
if (procinfo.id == myPid) {
strncpy(myName, procinfo.command, sizeof(myName));
break;
}
}
if (myName[0] == 0) {
return false; // Should never happen
}
// Search process list for other applications with same name
for (i=pm.begin(); i!=pm.end(); i++) {
PROCINFO& procinfo = i->second;
if (procinfo.id == myPid) continue;
if (!strcmp(procinfo.command, myName)) {
otherInstanceID = procinfo.id;
break;
}
}
return otherInstanceID;
}
示例6: app_running
bool app_running(PROC_MAP& pm, const char* p) {
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); ++i) {
PROCINFO& pi = i->second;
//msg_printf(0, MSG_INFO, "running: [%s]", pi.command);
if (!strcasecmp(pi.command, p)) {
return true;
}
}
return false;
}
示例7: get_descendants_aux
static void get_descendants_aux(PROC_MAP& pm, int pid, vector<int>& pids) {
PROC_MAP::iterator i = pm.find(pid);
if (i == pm.end()) return;
PROCINFO& p = i->second;
if (p.scanned) return; // avoid infinite recursion
p.scanned = true;
for (unsigned int j=0; j<p.children.size(); j++) {
int child_pid = p.children[j];
pids.push_back(child_pid);
get_descendants_aux(pm, child_pid, pids);
}
}
示例8: procinfo_show
void procinfo_show(PROCINFO& pi, PROC_MAP& pm) {
unsigned int i;
memset(&pi, 0, sizeof(pi));
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); i++) {
PROCINFO& p = i->second;
pi.kernel_time += p.kernel_time;
pi.user_time += p.user_time;
msg_printf(NULL, MSG_INFO, "%d %s: boinc %d low %d (%f %f) total (%f %f)",
p.id, p.command, p.is_boinc_app, p.is_low_priority, p.kernel_time, p.user_time, pi.kernel_time, pi.user_time
);
}
}
示例9: procinfo_non_boinc
// get resource usage of non-BOINC apps
//
void procinfo_non_boinc(PROCINFO& pi, PROC_MAP& pm) {
pi.clear();
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); i++) {
PROCINFO& p = i->second;
#ifdef _WIN32
if (p.id == 0) continue; // idle process
#endif
if (p.is_boinc_app) continue;
if (p.is_low_priority) continue;
pi.kernel_time += p.kernel_time;
pi.user_time += p.user_time;
pi.swap_size += p.swap_size;
pi.working_set_size += p.working_set_size;
}
}
示例10: IsBOINCCoreRunning
bool CBOINCClientManager::IsBOINCCoreRunning() {
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCClientManager::IsBOINCCoreRunning - Function Begin"));
bool running = false;
PROC_MAP pm;
int retval;
#ifndef __WXMSW__
if (m_lBOINCCoreProcessId) {
// Prevent client from being a zombie
if (waitpid(m_lBOINCCoreProcessId, 0, WNOHANG) == m_lBOINCCoreProcessId) {
m_lBOINCCoreProcessId = 0;
}
}
#endif
// Look for BOINC Client in list of all running processes
retval = procinfo_setup(pm);
if (retval) return false; // Should never happen
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); ++i) {
PROCINFO& pi = i->second;
#ifdef __WXMSW__
if (!strcmp(pi.command, "boinc.exe"))
#else
if (!strcmp(pi.command, "boinc"))
#endif
{
running = true;
break;
}
if (!strcmp(pi.command, "boinc_client")) {
running = true;
break;
}
}
wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::IsBOINCCoreRunning - Returning '%d'"), (int)running);
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCClientManager::IsBOINCCoreRunning - Function End"));
return running;
}
示例11: procinfo_show
void procinfo_show(PROC_MAP& pm) {
PROCINFO pi;
pi.clear();
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); ++i) {
PROCINFO& p = i->second;
msg_printf(NULL, MSG_INFO, "%d %s: boinc? %d low_pri %d (u%f k%f)",
p.id, p.command, p.is_boinc_app, p.is_low_priority,
p.user_time, p.kernel_time
);
#ifdef _WIN32
if (p.id == 0) continue;
#endif
if (p.is_boinc_app) continue;
if (p.is_low_priority) continue;
pi.kernel_time += p.kernel_time;
pi.user_time += p.user_time;
}
msg_printf(NULL, MSG_INFO, "non-boinc: u%f k%f", pi.user_time, pi.kernel_time);
}
示例12: KillClient
void CBOINCClientManager::KillClient() {
PROC_MAP pm;
int retval;
if (m_lBOINCCoreProcessId) {
kill_program(m_lBOINCCoreProcessId);
return;
}
retval = procinfo_setup(pm);
if (retval) return; // Should never happen
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); i++) {
PROCINFO& procinfo = i->second;
if (!strcmp(procinfo.command, "boinc")) {
kill_program(procinfo.id);
break;
}
}
}
示例13: launch_vboxsvc
// Launch VboxSVC.exe before going any further. if we don't, it'll be launched by
// svchost.exe with its environment block which will not contain the reference
// to VBOX_USER_HOME which is required for running in the BOINC account-based
// sandbox on Windows.
int VBOX_BASE::launch_vboxsvc() {
APP_INIT_DATA aid;
PROC_MAP pm;
PROCINFO p;
string command;
int retval = ERR_EXEC;
#ifdef _WIN32
char buf[256];
STARTUPINFO si;
PROCESS_INFORMATION pi;
int pidVboxSvc = 0;
HANDLE hVboxSvc = NULL;
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
boinc_get_init_data_p(&aid);
if (aid.using_sandbox) {
if (!vboxsvc_pid_handle || !process_exists(vboxsvc_pid_handle)) {
if (vboxsvc_pid_handle) CloseHandle(vboxsvc_pid_handle);
procinfo_setup(pm);
for (PROC_MAP::iterator i = pm.begin(); i != pm.end(); ++i) {
p = i->second;
// We are only looking for vboxsvc
if (0 != stricmp(p.command, "vboxsvc.exe")) continue;
// Store process id for later use
pidVboxSvc = p.id;
// Is this the vboxsvc for the current user?
// Non-service install it would be the current username
// Service install it would be boinc_project
hVboxSvc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, p.id);
if (hVboxSvc) break;
}
if (pidVboxSvc && hVboxSvc) {
vboxlog_msg("Status Report: Detected vboxsvc.exe. (PID = '%d')", pidVboxSvc);
vboxsvc_pid = pidVboxSvc;
vboxsvc_pid_handle = hVboxSvc;
retval = BOINC_SUCCESS;
} else {
si.cb = sizeof(STARTUPINFO);
si.dwFlags |= STARTF_FORCEOFFFEEDBACK | STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
command = "\"VBoxSVC.exe\" --logrotate 1";
CreateProcess(
NULL,
(LPTSTR)command.c_str(),
NULL,
NULL,
TRUE,
CREATE_NO_WINDOW,
NULL,
(LPTSTR)virtualbox_home_directory.c_str(),
&si,
&pi
);
if (pi.hThread) CloseHandle(pi.hThread);
if (pi.hProcess) {
vboxlog_msg("Status Report: Launching vboxsvc.exe. (PID = '%d')", pi.dwProcessId);
vboxsvc_pid = pi.dwProcessId;
vboxsvc_pid_handle = pi.hProcess;
retval = BOINC_SUCCESS;
} else {
vboxlog_msg("Status Report: Launching vboxsvc.exe failed!.");
vboxlog_msg(" Error: %s", windows_format_error_string(GetLastError(), buf, sizeof(buf)));
#ifdef _DEBUG
vboxlog_msg("Vbox Version: '%s'", virtualbox_version_raw.c_str());
vboxlog_msg("Vbox Install Directory: '%s'", virtualbox_install_directory.c_str());
vboxlog_msg("Vbox Home Directory: '%s'", virtualbox_home_directory.c_str());
#endif
}
string s = string("");
vbm_trace(command, s, retval);
}
}
}
#endif
return retval;
}
示例14: IsBOINCCoreRunning
bool CBOINCClientManager::IsBOINCCoreRunning() {
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCClientManager::IsBOINCCoreRunning - Function Begin"));
bool running = false;
#ifdef __WXMSW__
char buf[MAX_PATH] = "";
if (is_daemon_installed()) {
running = (FALSE != is_daemon_starting()) || (FALSE != is_daemon_running());
} else {
// Global mutex on Win2k and later
//
safe_strcpy(buf, "Global\\");
strcat( buf, RUN_MUTEX);
HANDLE h = CreateMutexA(NULL, true, buf);
DWORD err = GetLastError();
if ((h==0) || (err == ERROR_ALREADY_EXISTS)) {
running = true;
}
if (h) {
CloseHandle(h);
}
}
#elif defined(__WXMAC__)
char path[1024];
static FILE_LOCK file_lock;
sprintf(path, "%s/%s", (const char *)wxGetApp().GetDataDirectory().mb_str(), LOCK_FILE_NAME);
if (boinc_file_exists(path)) { // If there is no lock file, core is not running
if (file_lock.lock(path)) {
running = true;
} else {
file_lock.unlock(path);
}
}
#else
PROC_MAP pm;
int retval;
if (m_lBOINCCoreProcessId) {
// Prevent client from being a zombie
if (waitpid(m_lBOINCCoreProcessId, 0, WNOHANG) == m_lBOINCCoreProcessId) {
m_lBOINCCoreProcessId = 0;
}
}
// Look for BOINC Client in list of all running processes
retval = procinfo_setup(pm);
if (retval) return false; // Should never happen
PROC_MAP::iterator i;
for (i=pm.begin(); i!=pm.end(); i++) {
PROCINFO& pi = i->second;
if (!strcmp(pi.command, "boinc")) {
running = true;
break;
}
if (!strcmp(pi.command, "boinc_client")) {
running = true;
break;
}
}
#endif
wxLogTrace(wxT("Function Status"), wxT("CBOINCClientManager::IsBOINCCoreRunning - Returning '%d'"), (int)running);
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCClientManager::IsBOINCCoreRunning - Function End"));
return running;
}