You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4 KiB
C++

//
// Created by anton on 6/24/22.
//
#include "global_thread_pool.h"
namespace pmp::core {
// public
frame_id_t global_thread_pool::insert_frame(void *argument, void *scope, call_frame_target *target_function, frame_id_t parent) {
assert(("ThreadPool must be active when inserting! stop() or join() were called too early!", m_active));
frame_id_t id = m_last_id++;
return id;
}
void global_thread_pool::join() {
assert(m_active);
stop();
std::cout << "joining..." << std::endl;
for (size_t i = 0; i < m_thread_count; i++) {
if (m_threads[i].joinable()) {
m_threads[i].join();
std::cout << "thread " << i << " joined!" << std::endl;
} else {
std::cout << "thread " << i << " not joinable" << std::endl;
}
}
std::cout << "done!" << std::endl;
std::cout << "GlobalThreadPool finished!" << std::endl;
}
// private
void global_thread_pool::worker() {
// std::cout << "Hello from worker #" << std::this_thread::get_id() << std::endl;
using namespace std::chrono_literals;
call_frame* current = m_root_frame;
while (true) {
break;
if (!current->evaluate()) {
// someone else was faster
}
}
}
}