-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
97 changed files
with
1,474 additions
and
4,666 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
include(CheckCXXCompilerFlag) | ||
|
||
set(CMAKE_REQUIRED_QUIET true) | ||
function(enable_cxx_compiler_flag_if_supported flag) | ||
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_already_set) | ||
if (flag_already_set EQUAL -1) | ||
check_cxx_compiler_flag("${flag}" flag_supported) | ||
if (flag_supported) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE) | ||
message(" [ OK ] Compiler flag: ${flag}") | ||
else () | ||
message(" [ERROR] Compiler flag: ${flag} <--(Not supported)") | ||
endif () | ||
unset(flag_supported CACHE) | ||
else () | ||
message(" [WARN ] Compiler flag: ${flag} <--(Already set)") | ||
endif () | ||
endfunction() | ||
|
||
function(compiler_flags) | ||
message("Setting Compiler Flags:") | ||
foreach (flag ${ARGN}) | ||
enable_cxx_compiler_flag_if_supported("${flag}") | ||
endforeach () | ||
endfunction() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
enable_testing() | ||
|
||
FILE(GLOB_RECURSE TEST_LIST | ||
${CMAKE_CURRENT_LIST_DIR}/../test/**/*.cpp | ||
) | ||
foreach (test ${TEST_LIST}) | ||
get_filename_component(TName ${test} NAME_WLE) | ||
add_executable(${TName} ${test}) | ||
target_link_libraries(${TName} PRIVATE cyd_ui) | ||
target_include_directories(${TName} PRIVATE ${TEST_DIR}/common) | ||
|
||
file(STRINGS ${test} TLines) | ||
message("TEST CASES") | ||
foreach (line ${TLines}) | ||
if ("${line}" MATCHES "TEST\\(\"(.*)\"\\)") | ||
message("${line}") | ||
set(case ${CMAKE_MATCH_1}) | ||
message("${case}") | ||
|
||
add_test(NAME "${TName} - ${case}" COMMAND $<TARGET_FILE:${TName}> "${case}") | ||
endif () | ||
endforeach () | ||
endforeach () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
add_custom_target( | ||
cyd_ui_docs | ||
COMMAND /usr/bin/doxygen ${CMAKE_CURRENT_LIST_DIR}/../Doxyfile | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/.. | ||
COMMENT "Generating DOXYGEN documentation..." | ||
) | ||
add_custom_command(TARGET cyd_ui_docs PRE_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E make_directory docs | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/.. | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) 2024, Victor Castillo, All rights reserved. | ||
|
||
#ifndef CYD_UI_ASYNC_BUS_H | ||
#define CYD_UI_ASYNC_BUS_H | ||
|
||
#include "event_queue.h" | ||
#include "coroutine_runtime.h" | ||
|
||
namespace cydui::async { | ||
enum class async_bus_status_e { | ||
RUNNING, | ||
STOPPED, | ||
}; | ||
|
||
class async_bus_t: public event_queue_t, | ||
public coroutine_runtime_t { | ||
public: /// @name Construction & RAII | ||
// ! Constructor | ||
async_bus_t() { | ||
thread_start(); | ||
} | ||
// ! Destructor | ||
~async_bus_t() { | ||
thread_stop(); | ||
} | ||
// ! Copy | ||
async_bus_t(const async_bus_t &rhs) = delete; | ||
async_bus_t &operator=(const async_bus_t &rhs) = delete; | ||
// ! Move | ||
async_bus_t(async_bus_t &&rhs) = delete; | ||
async_bus_t &operator=(async_bus_t &&rhs) = delete; | ||
|
||
private TEST_PUBLIC: /// @name Status | ||
std::atomic<async_bus_status_e> status = async_bus_status_e::STOPPED; | ||
private TEST_PUBLIC: /// @name Thread | ||
std::unique_ptr<std::thread> thread = nullptr; | ||
void thread_start() { | ||
if (!thread) { | ||
status = async_bus_status_e::RUNNING; | ||
thread = std::make_unique<std::thread>([](async_bus_t* bus) {bus->thread_task();}, this); | ||
} | ||
} | ||
void thread_stop() { | ||
if (thread) { | ||
status = async_bus_status_e::STOPPED; | ||
thread->join(); | ||
thread.reset(nullptr); | ||
} | ||
} | ||
|
||
void thread_task() { | ||
using namespace std::chrono_literals; | ||
auto prev_t = std::chrono::system_clock::now(); | ||
while (status == async_bus_status_e::RUNNING) { | ||
prev_t = std::chrono::system_clock::now(); | ||
events_process_batch(); | ||
coroutine_run(); | ||
std::this_thread::sleep_until(prev_t + 100us); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
#endif //CYD_UI_ASYNC_BUS_H |
Oops, something went wrong.