#include #include #include #include #include #include #include #include #include struct Foo { int bar = 1; float baz = 2.0; // IMPL: Format String fmt_to_str() { auto h = ObjFmtHelper("Foo"); h.add_field("bar", this->bar); h.add_field("baz", this->baz); return h.finish(); } }; Vec test_vec() { Vec v = Vec(); v.push(1); v.push(2); v.push(3); v.push(4); return v; } void test_fmt(Vec v) { Foo f = Foo(); println("Hello!!!! {}, {}, {}, {}", "meow", 420.0, 49, v); println("> {}", f); } extern "C" void* test_mutex_thread(void* arg) { Mutex* m = (Mutex*)arg; auto val = m->lock(); println("mutex: changing {} to 69", *val); *val = 69; println("mutex: 5 second eep!! (eepy boyo)"); sleep(5); return NULL; } void test_mutex() { Mutex* m = new Mutex(0); pthread_t thread; println("mutex: Creating thread for mutex"); if (pthread_create(&thread, NULL, test_mutex_thread, (void*)m) != 0) { println("Uh oh (mutex)"); } pthread_join(thread, NULL); auto val = m->lock(); println("mutex: Value was {}", *val); } extern "C" void* test_spinlock_thread(void* arg) { SpinLock* sl = (SpinLock*)arg; println("spinlock: changing {} to 5", *sl->lock()); *sl->lock() = 5; println("spinlock: 5 second eep!! (eepy girlie)"); sleep(5); return NULL; } void test_spinlock() { SpinLock* sl = new SpinLock(0); pthread_t thread; println("spinlock: Creating thread for spinlock"); if (pthread_create(&thread, NULL, test_spinlock_thread, (void*)sl) != 0) { println("Uh oh (spinlock)"); } pthread_join(thread, NULL); println("spinlock: Value was {}", *sl->lock()); } /// https://github.com/yosh-matsuda/field-reflection int main(int argc, char* argv[]) { // Vec v = test_vec(); // test_fmt(v); // test_spinlock(); // test_mutex(); log::debug("hemlo!!"); log::info("hemlo!!"); log::warn("hemlo!!"); log::error("hemlo!!"); return 0; }