Refactor Input/Output file to use const char* instead of standard string, and to use parent_folder and file_name for input and output files. This also incorporates the move from nearby_connections to nearby.

PiperOrigin-RevId: 415587802
This commit is contained in:
jfcarroll
2021-12-10 12:49:50 -08:00
committed by Copybara-Service
parent 5ba6623eac
commit f12bb6c405
48 changed files with 540 additions and 377 deletions
+13 -2
View File
@@ -125,20 +125,25 @@ TEST(ExecutorTests, SingleThreadedExecutorMultipleTasksSucceeds) {
// Container to note threads that ran
std::unique_ptr<std::vector<DWORD>> threadIds =
std::make_unique<std::vector<DWORD>>();
CRITICAL_SECTION crit_sec;
InitializeCriticalSection(&crit_sec);
threadIds->push_back(GetCurrentThreadId());
// Act
for (int index = 0; index < 5; index++) {
executor->Execute([&output, &threadIds, index]() {
executor->Execute([&output, &threadIds, &crit_sec, index]() {
EnterCriticalSection(&crit_sec);
threadIds->push_back(GetCurrentThreadId());
char buffer[128];
snprintf(buffer, sizeof(buffer), "%s%d, ", RUNNABLE_TEXT.c_str(), index);
output.append(std::string(buffer));
LeaveCriticalSection(&crit_sec);
});
}
executor->Shutdown();
DeleteCriticalSection(&crit_sec);
// Assert
// We should've run 1 time on the main thread, and 5 times on the
@@ -200,19 +205,25 @@ TEST(ExecutorTests, MultiThreadedExecutorMultipleTasksSucceeds) {
std::shared_ptr<std::string> output = std::make_shared<std::string>();
CRITICAL_SECTION crit_sec;
InitializeCriticalSection(&crit_sec);
threadIds->push_back(GetCurrentThreadId());
// Act
for (int index = 0; index < 5; index++) {
executor->Execute([&output, &threadIds, index]() {
executor->Execute([&output, &threadIds, &crit_sec, index]() {
EnterCriticalSection(&crit_sec);
threadIds->push_back(GetCurrentThreadId());
char buffer[128];
snprintf(buffer, sizeof(buffer), "%s %d, ", RUNNABLE_TEXT.c_str(), index);
output->append(std::string(buffer));
LeaveCriticalSection(&crit_sec);
});
}
executor->Shutdown();
DeleteCriticalSection(&crit_sec);
// Assert
// We should've run 1 time on the main thread, and 5 times on the