diff --git a/.gitignore b/.gitignore
index 7f93ebf..a7de0c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
-venv
+/venv
__pycache__
+/dist
+/obj
+.ninja_log
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/customTargets.xml b/.idea/customTargets.xml
new file mode 100644
index 0000000..a6033b3
--- /dev/null
+++ b/.idea/customTargets.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/makefile.xml b/.idea/makefile.xml
new file mode 100644
index 0000000..6278399
--- /dev/null
+++ b/.idea/makefile.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+ runtime_lib/main.cpp
+
+
+
+
+
+
+
+
+ clean
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..1caec42
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Makefile b/Makefile
deleted file mode 100644
index e69de29..0000000
diff --git a/build.ninja b/build.ninja
new file mode 100644
index 0000000..a871e52
--- /dev/null
+++ b/build.ninja
@@ -0,0 +1,11 @@
+cflags = -Wall -Wextra -g
+print_flags = -fdiagnostics-color=always
+
+libraries = -lsodium
+
+rule cc
+ command = g++ $print_flags $cflags $libraries $in -o $out
+
+build dist/main: cc runtime_lib/main.cpp
+
+
diff --git a/runtime_lib/ProgramQueue.h b/runtime_lib/ProgramQueue.h
index 3f59c93..6a2a319 100644
--- a/runtime_lib/ProgramQueue.h
+++ b/runtime_lib/ProgramQueue.h
@@ -1,2 +1,117 @@
#pragma once
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+
+using call_frame_target = void*call_frame_target(void*, void*);
+
+struct packaged_call_frame {
+ void* arguments;
+}
+
+class package_of_work {
+ public:
+
+ package_of_work(int kind, call_frame_target target, void* scope_) :
+ kind_id(kind), work_factor(1), target_function(target), scope(scope_), finalized(false)
+ {
+ queue = std::queue()
+ }
+
+ int kind_id;
+ float work_factor;
+ std::queue queue;
+
+ call_frame_target target_function;
+ void* scope;
+
+ bool finalized;
+}
+
+struct call_frame {
+ void* arguments;
+ void* scope;
+ call_frame_target target_function;
+ int id;
+}
+
+struct call_result {
+ int nothing;
+}
+
+
+class GlobalThreadPool {
+ public:
+ GlobalThreadPool();
+
+ int create_package(void* scope, call_frame_target target_function);
+ void submit_to_package(int kind_id, void* arguments);
+ struct call_result join_package(int kind_id);
+
+
+ private:
+ std::unordered_map m_work_packages;
+ std::stack m_work_package_stack;
+ std::mutex m_work_packages_lock;
+
+ std::queue m_calls;
+ std::mutex m_calls_lock;
+
+ std::unordered_map m_results;
+ std::mutex m_results_lock;
+
+ volatile int m_last_id;
+ std::mutex m_id_lock;
+
+ std::vector m_trheads;
+
+ void thread_worker();
+}
+
+void GlobalThreadPool::thread_worker() {
+ using namespace std::chrono_literals;
+ package_of_work* current = NULL;
+
+ while (true) {
+ if (m_work_package_stack.size > 0) {
+ // grab a reference to the first queue
+ current = m_work_package_stack.top;
+ }
+
+ // if not finalized, try again
+ if (!current->finalized && current->queue.size == 0) {
+ std::this_thread::sleep_for(100ms);
+ continue
+ }
+
+
+
+ }
+
+}
+
+int GlobalThreadPool::create_package(void* scope, call_frame_target target_function)
+{
+ this->id_lock.lock()
+ int kind_id = this->last_id++;
+ this->id_lock.unlock()
+
+ this->work_packages_lock.lock()
+ auto package = package_of_work(kind_id, target_function, scope);
+ this->work_packages[kind_id] = package;
+ this->work_package_stack.push(package);
+ this->work_packages_lock.unlock()
+
+ return kind_id;
+}
+
+
diff --git a/runtime_lib/main.cpp b/runtime_lib/main.cpp
new file mode 100644
index 0000000..133403a
--- /dev/null
+++ b/runtime_lib/main.cpp
@@ -0,0 +1,240 @@
+//
+// Created by anton on 6/22/22.
+//
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include