├── .idea
├── iara.iml
├── codeStyles
│ └── codeStyleConfig.xml
├── .gitignore
├── vcs.xml
├── modules.xml
├── customTargets.xml
└── misc.xml
├── utils
├── src
│ ├── logger.cpp
│ └── format.cpp
└── include
│ └── utils
│ ├── inclusion.hpp
│ ├── object-buffer.hpp
│ ├── format.hpp
│ ├── object-pool.hpp
│ ├── resource-guard.hpp
│ ├── pool-allocator.hpp
│ ├── storage-for.hpp
│ ├── type-traits.hpp
│ ├── logger.hpp
│ ├── circular-queue.hpp
│ ├── test-helpers.hpp
│ └── types.hpp
├── plumbing
└── include
│ └── plumbing
│ ├── pipe-guard.hpp
│ ├── proxy.hpp
│ ├── source.hpp
│ ├── duplex.hpp
│ ├── sink.hpp
│ └── box.hpp
├── fugax
├── include
│ ├── fugax.hpp
│ └── fugax
│ │ ├── event-listener.hpp
│ │ ├── event-guard.hpp
│ │ ├── event.hpp
│ │ └── event-loop.hpp
├── src
│ ├── event-guard.cpp
│ ├── event.cpp
│ └── event-loop.cpp
└── README.md
├── test
├── include
│ └── test
│ │ ├── juro
│ │ └── helpers.hpp
│ │ └── fugax
│ │ └── helpers.hpp
└── src
│ ├── fuss
│ └── test.cpp
│ └── fugax
│ └── test.cpp
├── juro
├── src
│ ├── compose
│ │ └── all.cpp
│ └── promise.cpp
└── include
│ └── juro
│ ├── compose
│ ├── race.hpp
│ └── all.hpp
│ ├── factories.hpp
│ ├── helpers.hpp
│ └── promise.hpp
├── CMakePresets.json
├── LICENSE
├── .github
└── workflows
│ └── cmake.yml
├── config
└── include
│ └── config
│ └── fugax.hpp.in
├── fuss
├── README.md
└── include
│ └── fuss.hpp
├── .gitignore
├── CMakeLists.txt
└── README.md
/.idea/iara.iml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/utils/src/logger.cpp:
--------------------------------------------------------------------------------
1 | #include "utils/logger.hpp"
2 |
3 | namespace utils {
4 | constexpr const char *logger_scope::entry_tags[];
5 | } /* namespace utils */
6 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/plumbing/include/plumbing/pipe-guard.hpp:
--------------------------------------------------------------------------------
1 | #ifndef PLUMBING_PIPE_GUARD_HPP
2 | #define PLUMBING_PIPE_GUARD_HPP
3 |
4 | namespace plumbing {
5 |
6 |
7 |
8 | } /* namespace plumbing */
9 |
10 | #endif /* PLUMBING_PIPE_GUARD_HPP */
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/fugax/include/fugax.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file fugax/include/fugax.hpp
3 | * @brief Main include header for Fugax
4 | * @author kazeshi
5 | * @date 22/06/23
6 | * @copyright (C) 2023 kazeshi
7 | **/
8 |
9 | #ifndef FUGAX_HPP
10 | #define FUGAX_HPP
11 |
12 | #include "fugax/event-loop.hpp"
13 |
14 | #endif /* FUGAX_HPP */
15 |
--------------------------------------------------------------------------------
/.idea/customTargets.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/test/include/test/juro/helpers.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file test/include/test/juro/helpers.hpp
3 | * @brief Helper functions and structures for testing purposes
4 | * @author André Medeiros
5 | * @date 31/07/23
6 | * @copyright 2023 (C) André Medeiros
7 | **/
8 | #ifndef JURO_TEST_HELPERS_HPP
9 | #define JURO_TEST_HELPERS_HPP
10 |
11 | namespace juro::test::helpers {
12 |
13 | } /* namespace juro::test::helpers */
14 |
15 | #endif /* JURO_TEST_HELPERS_HPP */
--------------------------------------------------------------------------------
/utils/include/utils/inclusion.hpp:
--------------------------------------------------------------------------------
1 | #ifndef UTILS_INCLUSION_HPP
2 | #define UTILS_INCLUSION_HPP
3 |
4 | namespace utils {
5 |
6 | template
7 | struct includes {
8 | static constexpr bool value = false;
9 | };
10 |
11 | template
12 | struct includes {
13 | static constexpr bool value =
14 | std::is_same::value || includes::value;
15 | };
16 |
17 | } /* namespace utils */
18 |
19 | #endif /* UTILS_INCLUSION_HPP */
--------------------------------------------------------------------------------
/utils/src/format.cpp:
--------------------------------------------------------------------------------
1 | #include "utils/format.hpp"
2 |
3 | #ifndef _GNU_SOURCE
4 | #error "Macro _GNU_SOURCE must be defined for formatting support"
5 | #endif
6 |
7 | namespace utils {
8 |
9 | [[gnu::format(printf, 1, 2)]]
10 | std::string format(const char *fmt, ...) {
11 | std::va_list scan_args;
12 | va_start(scan_args, fmt);
13 |
14 | char *formatted;
15 | std::size_t size = vasprintf(&formatted, fmt, scan_args);
16 | std::string result { formatted, size };
17 | free(formatted);
18 | return result;
19 | }
20 |
21 | } /* namespace utils */
--------------------------------------------------------------------------------
/juro/src/compose/all.cpp:
--------------------------------------------------------------------------------
1 | #include "juro/promise.hpp"
2 | #include "juro/compose/all.hpp"
3 |
4 | namespace juro::compose {
5 |
6 | void void_settler(const promise_ptr &promise, const promise_ptr &all_promise, const std::shared_ptr &counter) {
7 | promise->then([counter, all_promise] {
8 | if(--(*counter) == 0 && all_promise->is_pending()) {
9 | all_promise->resolve();
10 | }
11 | }, [all_promise] (std::exception_ptr error) {
12 | if(all_promise->is_pending()) {
13 | all_promise->reject(error);
14 | }
15 | });
16 | }
17 |
18 | } /* namespace juro::compose */
--------------------------------------------------------------------------------
/fugax/src/event-guard.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file fugax/src/event-guard.cpp
3 | * @brief Implementation of non-templated event guard functions
4 | * @author André Medeiros
5 | * @date 22/06/23
6 | * @copyright 2023 (C) André Medeiros
7 | **/
8 |
9 | #include "fugax/event-guard.hpp"
10 |
11 | namespace fugax {
12 |
13 | event_guard &event_guard::operator=(event_guard &&other) noexcept {
14 | release();
15 | listener = std::move(other.listener);
16 | return *this;
17 | }
18 |
19 | void event_guard::release() const noexcept {
20 | if(const auto target = listener.lock()) {
21 | target->cancel();
22 | }
23 | }
24 |
25 | } /* namespace fugax */
--------------------------------------------------------------------------------
/fugax/include/fugax/event-listener.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file fugax/include/fugax/event-listener.hpp
3 | * @brief Contains the definition of event listeners
4 | * @author André Medeiros
5 | * @date 22/06/23
6 | * @copyright 2023 (C) André Medeiros
7 | **/
8 |
9 | #ifndef FUGAX_EVENT_LISTENER_HPP
10 | #define FUGAX_EVENT_LISTENER_HPP
11 |
12 | #include
13 | #include "event.hpp"
14 |
15 | namespace fugax {
16 |
17 | /**
18 | * @brief An event listener is a handle that can be used to cancel an event,
19 | * given it hasn't been executed yet
20 | */
21 | using event_listener = std::weak_ptr;
22 |
23 | } /* namespace fugax */
24 |
25 | #endif /* FUGAX_EVENT_LISTENER_HPP */
26 |
--------------------------------------------------------------------------------
/utils/include/utils/object-buffer.hpp:
--------------------------------------------------------------------------------
1 | #ifndef OBJECT_BUFFER_HPP
2 | #define OBJECT_BUFFER_HPP
3 |
4 | template
5 | struct object_buffer {
6 | alignas(T) unsigned char data[sizeof(T)];
7 |
8 | template
9 | T &construct(T_args &... args) {
10 | return *new(reinterpret_cast(&data)) T(args ...);
11 | }
12 |
13 | void destruct() {
14 | reinterpret_cast(&data)->~T();
15 | }
16 |
17 | operator T &() const {
18 | return *reinterpret_cast(&data);
19 | }
20 |
21 | operator T &() {
22 | return *reinterpret_cast(&data);
23 | }
24 | };
25 |
26 | #endif /* OBJECT_BUFFER_HPP */
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/CMakePresets.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 6,
3 | "cmakeMinimumRequired": {
4 | "major": 3,
5 | "minor": 25,
6 | "patch": 0
7 | },
8 | "configurePresets": [
9 | {
10 | "name": "default",
11 | "displayName": "Default configure preset",
12 | "description": "A preset with sensible default values that can be overridden",
13 | "cacheVariables": {
14 | "FUGAX_TIME_INCLUDE": "",
15 | "FUGAX_TIME_TYPE": "std::uint_fast32_t",
16 | "FUGAX_MUTEX_INCLUDE": "",
17 | "FUGAX_MUTEX_TYPE": "std::mutex"
18 | }
19 | }
20 | ],
21 | "buildPresets": [
22 | {
23 | "name": "default",
24 | "displayName": "Default build preset",
25 | "configurePreset": "default"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/juro/src/promise.cpp:
--------------------------------------------------------------------------------
1 | #include "juro/promise.hpp"
2 |
3 | namespace juro {
4 |
5 | promise_interface::promise_interface(promise_state state) noexcept :
6 | state { state }
7 | { }
8 |
9 | void promise_interface::set_settle_handler(std::function &&handler) noexcept {
10 | on_settle = std::move(handler);
11 | if(is_settled()) {
12 | on_settle();
13 | }
14 | }
15 |
16 | void promise_interface::resolved() noexcept {
17 | state = promise_state::RESOLVED;
18 | if(on_settle) {
19 | on_settle();
20 | }
21 | }
22 |
23 | void promise_interface::rejected() {
24 | state = promise_state::REJECTED;
25 | if(on_settle) {
26 | on_settle();
27 | } else {
28 | throw promise_error { "Unhandled promise rejection" };
29 | }
30 | }
31 |
32 | } /* namespace juro */
--------------------------------------------------------------------------------
/fugax/src/event.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file fugax/src/event.cpp
3 | * @brief Implementation of non-templated event functions
4 | * @author André Medeiros
5 | * @date 26/06/23
6 | * @copyright 2023 (C) André Medeiros
7 | */
8 |
9 | #include "fugax/event.hpp"
10 |
11 | namespace fugax {
12 |
13 | void event_handler::operator()(event &ev) const { handler->invoke(ev); }
14 |
15 | event::event(event_handler &&handler, time_type interval, time_type due_time, bool recurring) :
16 | handler { std::forward(handler) },
17 | interval { interval },
18 | due_time { due_time },
19 | recurring { recurring }
20 | { }
21 |
22 | void event::fire() { handler(*this); }
23 | void event::cancel() noexcept { cancelled = true; }
24 | void event::reschedule(time_type time_point) noexcept { due_time = time_point; }
25 |
26 | } /* namespace fugax */
--------------------------------------------------------------------------------
/utils/include/utils/format.hpp:
--------------------------------------------------------------------------------
1 | #ifndef UTILS_FORMAT_HPP
2 | #define UTILS_FORMAT_HPP
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "types.hpp"
9 |
10 | namespace utils {
11 |
12 | [[gnu::format(printf, 1, 2)]]
13 | std::string format(const char *fmt, ...);
14 |
15 |
16 | template
17 | class formatter {
18 | const char *fmt;
19 |
20 | public:
21 | explicit constexpr formatter(const char *fmt) noexcept :
22 | fmt { fmt }
23 | { }
24 |
25 | formatter(const formatter &) noexcept = default;
26 | formatter(formatter &&) noexcept = default;
27 |
28 | formatter &operator=(const formatter &) noexcept = default;
29 | formatter &operator=(formatter &&) noexcept = default;
30 | virtual ~formatter() noexcept = default;
31 |
32 | std::string operator()(const T_args &...args) const {
33 | return format(fmt, args...);
34 | }
35 | };
36 |
37 | } /* namespace utils */
38 |
39 | #endif /* UTILS_FORMAT_HPP */
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 André Medeiros
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/utils/include/utils/object-pool.hpp:
--------------------------------------------------------------------------------
1 | #ifndef OBJECT_POOL_HPP
2 | #define OBJECT_POOL_HPP
3 |
4 |
5 | #include "object-buffer.hpp"
6 | #include "circular-queue.hpp"
7 | #include
8 |
9 | template
10 | class object_pool {
11 |
12 | using object = object_buffer;
13 | static constexpr std::size_t factor = 1< blocks;
16 | circular_queue