The SVSync class provides functionality for Thread & Process Creation.
More...
#include <svutil.h>
The SVSync class provides functionality for Thread & Process Creation.
Definition at line 46 of file svutil.h.
◆ ExitThread()
void SVSync::ExitThread |
( |
| ) |
|
|
static |
Signals a thread to exit.
Definition at line 111 of file svutil.cpp.
115 pthread_exit(
nullptr);
◆ StartProcess()
void SVSync::StartProcess |
( |
const char * |
executable, |
|
|
const char * |
args |
|
) |
| |
|
static |
Starts a new process.
Definition at line 120 of file svutil.cpp.
122 proc.append(executable);
125 std::cout <<
"Starting " << proc << std::endl;
127 STARTUPINFO start_info;
128 PROCESS_INFORMATION proc_info;
129 GetStartupInfo(&start_info);
130 if (!CreateProcess(
nullptr, const_cast<char*>(proc.c_str()),
nullptr,
nullptr,
FALSE,
131 CREATE_NO_WINDOW | DETACHED_PROCESS,
nullptr,
nullptr,
132 &start_info, &proc_info))
141 prctl(PR_SET_PDEATHSIG, 2, 0, 0, 0);
143 char* mutable_args = strdup(args);
145 for (
int i = 0; mutable_args[i]; ++i) {
146 if (mutable_args[i] ==
' ') {
150 std::unique_ptr<char*[]> argv(
new char*[argc + 2]);
151 argv[0] = strdup(executable);
152 argv[1] = mutable_args;
154 bool inquote =
false;
155 for (
int i = 0; mutable_args[i]; ++i) {
156 if (!inquote && mutable_args[i] ==
' ') {
157 mutable_args[i] =
'\0';
158 argv[argc++] = mutable_args + i + 1;
159 }
else if (mutable_args[i] ==
'"') {
161 mutable_args[i] =
' ';
164 argv[argc] =
nullptr;
165 execvp(executable, argv.get());
◆ StartThread()
void SVSync::StartThread |
( |
void *(*)(void *) |
func, |
|
|
void * |
arg |
|
) |
| |
|
static |
Create new thread.
Definition at line 87 of file svutil.cpp.
89 LPTHREAD_START_ROUTINE f = (LPTHREAD_START_ROUTINE)func;
91 HANDLE newthread = CreateThread(
nullptr,
100 pthread_attr_init(&attr);
101 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
102 pthread_create(&helper, &attr, func, arg);
The documentation for this class was generated from the following files:
- /usr/src/tesseract-ocr.master/src/viewer/svutil.h
- /usr/src/tesseract-ocr.master/src/viewer/svutil.cpp