-
Notifications
You must be signed in to change notification settings - Fork 9
/
EmulatorThreader.cpp
74 lines (42 loc) · 1.04 KB
/
EmulatorThreader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// BizHawkThreader.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <vector>
#include <unistd.h>
#include <iostream>
#include <thread>
using namespace std;
/// path of emulator file
string PATH_OF_EMULATOR = "./";
///
int THREAD_AMOUNT = 3;
/** progam converts string to char array & executes program
*@param: string
*
*/
void RunEmulator( string &command)
{
const char* thread_execution = command.c_str();
system(thread_execution);
}
int main(int argc, char *argv[])
{
vector<thread> threads;
// change of directory, will make more dynamic once ready to merge
string current_command = PATH_OF_EMULATOR;
const char* val = current_command.c_str();
chdir(val);
current_command = "./EmuHawkMulti.exe --thread-count=";
for(int i= 1; i <= THREAD_AMOUNT; ++i)
{
current_command += to_string(i);
threads.emplace_back(bind(&RunEmulator, current_command ));
}
for (auto &t : threads)
{
t.join();
}
return EXIT_SUCCESS;
}