diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0eb44e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,71 @@ +# ---> SCons +# for projects that use SCons for building: http://http://www.scons.org/ +.sconsign.dblite + +# ---> C +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# binary files +bin/ +# test files +assets/ +# custom build tracking +compile_commands.json +# logs and some custom thoughts +log +thoughts + +*.swp +vgcore.* +*.pdf diff --git a/source/async.cpp b/source/async.cpp index a61f044..b4ab9fe 100644 --- a/source/async.cpp +++ b/source/async.cpp @@ -127,7 +127,19 @@ void EventLoop::leaveScope(){ local_loop = nullptr; } -bool EventLoop::poll(int timeout){ +bool EventLoop::wait(const std::chrono::steady_clock::duration& duration){ + return false; +} + +bool EventLoop::wait(const std::chrono::steady_clock::time_point& time_point){ + return false; +} + +bool EventLoop::wait(){ + return false; +} + +bool EventLoop::poll(){ return false; } @@ -142,7 +154,15 @@ WaitScope::~WaitScope(){ } void WaitScope::wait(){ + loop.wait(); +} +void WaitScope::wait(const std::chrono::steady_clock::duration& duration){ + loop.wait(duration); +} + +void WaitScope::wait(const std::chrono::steady_clock::time_point& time_point){ + loop.wait(time_point); } void WaitScope::poll(){ diff --git a/source/async.h b/source/async.h index d5c1c4d..ae53e1f 100644 --- a/source/async.h +++ b/source/async.h @@ -1,21 +1,31 @@ #pragma once -#include "time.h" +#include "timer.h" #include "common.h" #include namespace gin { +class ConveyorNode; + class ConveyorBase { +private: + Own node; public: virtual ~ConveyorBase() = default; }; + +template +class Conveyor : public ConveyorBase { + +}; + class EventLoop; class Event { private: EventLoop& loop; - Event* prev = nullptr; - Event** next = nullptr; + Event** prev = nullptr; + Event* next = nullptr; public: Event(EventLoop& loop); virtual ~Event(); @@ -44,16 +54,14 @@ private: friend class WaitScope; void enterScope(); void leaveScope(); - - bool wait(); - bool wait(const std::chrono::steady_clock::duration&); - bool poll(); - - class Impl; - Own impl; public: EventLoop(); ~EventLoop(); + + bool wait(); + bool wait(const std::chrono::steady_clock::duration&); + void wait(const std::chrono::steady_clock::time_point&); + bool poll(); }; class WaitScope { @@ -65,7 +73,11 @@ public: void wait(); void wait(const std::chrono::steady_clock::duration&); - void wait(const std::chrono::steady_clock::timepoint&); + void wait(const std::chrono::steady_clock::time_point&); void poll(); }; +} +// Template inlining +namespace ent { + } \ No newline at end of file diff --git a/source/async.o b/source/async.o new file mode 100644 index 0000000..5d4daf7 Binary files /dev/null and b/source/async.o differ diff --git a/source/common.h b/source/common.h index f95f08e..facbe1c 100644 --- a/source/common.h +++ b/source/common.h @@ -3,6 +3,7 @@ #include #include #include +#include namespace gin { @@ -14,8 +15,6 @@ namespace gin { classname(const classname&) = delete; \ classname& operator=(const classname&) = delete -// Need logger for that -//#define GIN_REQUIRE(statement, str) \ template using Maybe = std::optional; @@ -35,7 +34,7 @@ Own heap(Args&&... args){ } template -Share share(Args&&... args){ +Our share(Args&&... args){ return std::make_shared(std::forward(args)...); } diff --git a/source/error.o b/source/error.o new file mode 100644 index 0000000..cec880f Binary files /dev/null and b/source/error.o differ diff --git a/source/time.h b/source/timer.h similarity index 100% rename from source/time.h rename to source/timer.h diff --git a/test/SConscript b/test/SConscript index 43bc8fa..3ca75f2 100644 --- a/test/SConscript +++ b/test/SConscript @@ -10,6 +10,7 @@ dir_path = Dir('.').abspath env.test_sources = sorted(glob.glob(dir_path + "/*.cpp")) env_test = env.Clone() +env_test.Append(CPPDEFINES=['GIN_COMPILE_TEST_BINARY']) env.test_objects = [] env.test_sources.append(dir_path+'/suite/suite.cpp') diff --git a/test/async.cpp b/test/async.cpp new file mode 100644 index 0000000..3c186b7 --- /dev/null +++ b/test/async.cpp @@ -0,0 +1,13 @@ +#include "suite/suite.h" + +#include "async.h" + +using namespace gin; + +GIN_TEST("Async"){ + EventLoop event_loop; + + WaitScope wait_scope{event_loop}; + + wait_scope.wait(std::chrono::seconds{1}); +} \ No newline at end of file