Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@
path = third_party/gcem
url = https://github.com/aethernetio/gcem.git
branch = master
[submodule "third_party/stdexec"]
path = third_party/stdexec
url = https://github.com/aethernetio/stdexec.git
branch = main
32 changes: 19 additions & 13 deletions aether/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ list(APPEND common_dependencies
"../third_party/gcem"
"../third_party/etl"
"../third_party/aethernet-numeric"
"../third_party/stdexec"
)
set(STDEXEC_BUILD_EXAMPLES Off)

# for etl
set(GIT_DIR_LOOKUP_POLICY ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
Expand Down Expand Up @@ -359,7 +361,8 @@ if(REGULAR_CMAKE_PROJECT)
sodium
hydrogen
gcem
etl)
etl
stdexec)
target_link_libraries(${PROJECT_NAME} PRIVATE c-ares )

set(TARGET_NAME "${PROJECT_NAME}")
Expand Down Expand Up @@ -416,7 +419,8 @@ else()
sodium
hydrogen
gcem
etl)
etl
stdexec)
else()
#ERROR
message(SEND_ERROR "You must specify the CMAKE version!")
Expand Down Expand Up @@ -538,10 +542,12 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
PRIVATE
/W4
/WX
/w15262 #implisitfallthrough
/wd4388 #Wno-sign-compare
/wd4389 #Wno-sign-compare
/wd4244
/w15262 #implisitfallthrough
PUBLIC
/wd4100 /wd4101 /wd4127 /wd4244 /wd4324
/wd4456 /wd4459 /wd4714
)
target_compile_options(${TARGET_NAME} PUBLIC /Zc:preprocessor)
endif()
Expand All @@ -558,15 +564,15 @@ endif()

if(REGULAR_CMAKE_PROJECT AND NOT AE_BUILD_TESTS)
## Target installation
install(TARGETS ${TARGET_NAME}
EXPORT ${TARGET_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET_NAME}
COMPONENT library)
# install(TARGETS ${TARGET_NAME}
# EXPORT ${TARGET_NAME}Targets
# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET_NAME}
# COMPONENT library)

## Target's cmake files: targets export
install(EXPORT ${TARGET_NAME}Targets
NAMESPACE ${TARGET_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME})
#install(EXPORT ${TARGET_NAME}Targets
# NAMESPACE ${TARGET_NAME}::
# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME})
endif()
8 changes: 6 additions & 2 deletions aether/ae_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,30 @@ struct AeCtxTable {
};

struct AeCtx {
bool operator==(AeCtx const&) const = default;

void* obj;
AeCtxTable const* vtable;
};

template <typename T>
concept AeContextual = requires(T& t) {
concept AeContextual = requires(T const& t) {
{ t.ToAeContext() } -> std::same_as<AeCtx>;
};

class AeContext {
public:
template <AeContextual T>
constexpr AeContext(T& obj) // NOLINT(*explicit-constructor)
constexpr AeContext(T const& obj) // NOLINT(*explicit-constructor)
: ctx_{obj.ToAeContext()} {}

Aether& aether() const { return ctx_.vtable->aether_getter(ctx_.obj); }
TaskScheduler& scheduler() const {
return ctx_.vtable->scheduler_getter(ctx_.obj);
}

bool operator==(AeContext const&) const = default;

private:
AeCtx ctx_;
};
Expand Down
8 changes: 5 additions & 3 deletions aether/aether.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@ Aether::Aether(ObjProp prop)
Aether::~Aether() { AE_TELE_DEBUG(AetherDestroyed); }

void Aether::Update(TimePoint current_time) {
update_time = action_processor->Update(current_time);
task_scheduler->Update(current_time);
action_processor->Update(current_time);
update_time = current_time + 100ms;
}

Aether::operator ActionContext() const {
return ActionContext{*action_processor};
}

AeCtx Aether::ToAeContext() {
AeCtx Aether::ToAeContext() const {
static constexpr AeCtxTable ae_table{
[](void* obj) -> Aether& { return *static_cast<Aether*>(obj); },
[](void* obj) -> TaskScheduler& {
return *static_cast<Aether*>(obj)->task_scheduler;
},
};
return AeCtx{this, &ae_table};
return AeCtx{const_cast<Aether*>(this), &ae_table}; // NOLINT(*const-cast)
}

Client::ptr Aether::CreateClient(ClientConfig const& config,
Expand Down
2 changes: 1 addition & 1 deletion aether/aether.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Aether : public Obj {

// User-facing API.
operator ActionContext() const;
AeCtx ToAeContext();
AeCtx ToAeContext() const;

ObjPtr<Client> CreateClient(ClientConfig const& config,
std::string const& client_id);
Expand Down
1 change: 1 addition & 0 deletions aether/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "aether/ae_context.h"
#include "aether/aether_app.h"

#include "aether/executors/executors.h"
#include "aether/actions/action.h"
#include "aether/actions/action_ptr.h"
#include "aether/actions/action_context.h"
Expand Down
10 changes: 8 additions & 2 deletions aether/channels/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
#ifndef AETHER_CHANNELS_CHANNEL_H_
#define AETHER_CHANNELS_CHANNEL_H_

#include "aether/memory.h"
#include "aether/obj/obj.h"
#include "aether/executors/executors.h"
#include "aether/stream_api/istream.h"
#include "aether/channels/channels_types.h"
#include "aether/channels/channel_statistics.h"
#include "aether/transport/transport_builder_action.h"

namespace ae {
using TransportBuildSender =
ex::AnySender<ex::set_value_t(std::unique_ptr<ByteIStream>),
ex::set_error_t(int)>;

class Channel : public Obj {
AE_OBJECT(Channel, Obj, 0)

Expand All @@ -36,7 +42,7 @@ class Channel : public Obj {
/**
* \brief Make transport from this channel.
*/
virtual ActionPtr<TransportBuilderAction> TransportBuilder() = 0;
virtual TransportBuildSender TransportBuilder() = 0;

ChannelTransportProperties const& transport_properties() const;
ChannelStatistics& channel_statistics();
Expand Down
Loading
Loading