initial commit

This commit is contained in:
keldu.magnus 2020-08-06 02:19:05 +02:00
parent ced3d21327
commit fb6941af6f
9 changed files with 131 additions and 15 deletions

71
.gitignore vendored Normal file
View File

@ -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

View File

@ -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(){

View File

@ -1,21 +1,31 @@
#pragma once
#include "time.h"
#include "timer.h"
#include "common.h"
#include <list>
namespace gin {
class ConveyorNode;
class ConveyorBase {
private:
Own<ConveyorNode> node;
public:
virtual ~ConveyorBase() = default;
};
template<T>
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> 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 {
}

BIN
source/async.o Normal file

Binary file not shown.

View File

@ -3,6 +3,7 @@
#include <cstdint>
#include <memory>
#include <utility>
#include <optional>
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<typename T>
using Maybe = std::optional<T>;
@ -35,7 +34,7 @@ Own<T> heap(Args&&... args){
}
template<typename T, class... Args>
Share<T> share(Args&&... args){
Our<T> share(Args&&... args){
return std::make_shared<T>(std::forward<Args>(args)...);
}

BIN
source/error.o Normal file

Binary file not shown.

View File

@ -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')

13
test/async.cpp Normal file
View File

@ -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});
}