Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kotbegemot committed Jun 3, 2024
1 parent e9cf9d8 commit a23a7c9
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 36 deletions.
6 changes: 3 additions & 3 deletions examples/balancer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class collection_t final : public actor_zeta::cooperative_supervisor<collection_
});
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "collection";
}

Expand Down Expand Up @@ -74,7 +74,7 @@ class collection_t final : public actor_zeta::cooperative_supervisor<collection_
}

protected:
auto enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) -> void final {
bool enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) final {
set_current_message(std::move(msg));
behavior()(current_message());
}
Expand Down Expand Up @@ -106,7 +106,7 @@ class collection_part_t final : public actor_zeta::basic_actor<collection_part_t
++count_collection_part;
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "collection";
}

Expand Down
7 changes: 4 additions & 3 deletions examples/broadcast/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class supervisor_lite final : public actor_zeta::cooperative_supervisor<supervis
});
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "network";
}

Expand Down Expand Up @@ -79,9 +79,10 @@ class supervisor_lite final : public actor_zeta::cooperative_supervisor<supervis
auto make_scheduler() noexcept -> actor_zeta::scheduler_abstract_t* { return e_.get(); }

protected:
auto enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) -> void final {
bool enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) final {
set_current_message(std::move(msg));
behavior()(current_message());
return true;
}

private:
Expand Down Expand Up @@ -129,7 +130,7 @@ class worker_t final : public actor_zeta::basic_actor<worker_t> {
});
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "worker_t";
}

Expand Down
6 changes: 3 additions & 3 deletions examples/dataflow/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class supervisor_test_t final : public actor_zeta::cooperative_supervisor<superv
memchecker_thread_.join();
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return name_.c_str();
}

Expand All @@ -173,7 +173,7 @@ class supervisor_test_t final : public actor_zeta::cooperative_supervisor<superv
});
}

auto enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) -> void final {
bool enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) final {
{
auto ptr = msg.get();
set_current_message(std::move(msg));
Expand Down Expand Up @@ -211,7 +211,7 @@ class actor_test_t final : public actor_zeta::basic_actor<actor_test_t> {
, consumer_latency_ms_(consumer_latency_ms) {
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return name_.c_str();
}

Expand Down
5 changes: 3 additions & 2 deletions examples/timer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class supervisor_lite final : public actor_zeta::cooperative_supervisor<supervis
e_->start();
}

auto make_type() const noexcept -> const char* const {
auto make_type() const noexcept -> const char* {
return "supervisor_lite";
}

Expand Down Expand Up @@ -91,10 +91,11 @@ class supervisor_lite final : public actor_zeta::cooperative_supervisor<supervis
}
});
}
auto enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) -> void final {
bool enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) final {
{
set_current_message(std::move(msg));
behavior()(current_message());
return true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions header/actor-zeta/base/actor_abstract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace actor_zeta { namespace base {
actor_abstract* impl_{nullptr};
};

auto type() const noexcept -> const char* const;
auto type() const noexcept -> const char*;
auto id() const -> id_t;
bool enqueue(mailbox::message_ptr);
bool enqueue(mailbox::message_ptr, scheduler::execution_unit*);
Expand All @@ -91,7 +91,7 @@ namespace actor_zeta { namespace base {
~actor_abstract() override;

virtual bool enqueue_impl(mailbox::message_ptr, scheduler::execution_unit*) = 0;
virtual auto type_impl() const noexcept -> const char* const = 0;
virtual const char* type_impl() const noexcept = 0;

private:

Expand Down
17 changes: 10 additions & 7 deletions header/actor-zeta/base/detail/cooperative_actor_classic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace actor_zeta { namespace base {
return scheduler::resume_result::done;
}
size_t handled_msgs = 0;
mailbox::message_ptr ptr;
while (handled_msgs < max_throughput) {
auto ptr = mailbox().pop_front();
if (!ptr) {
Expand Down Expand Up @@ -60,10 +59,10 @@ namespace actor_zeta { namespace base {
, supervisor_([](supervisor_abstract*ptr) { assert(ptr);return ptr; }(static_cast<supervisor_abstract*>(ptr)))
, stack_(resource())
, mailbox_(std::forward<Args>(args)...) {
mailbox().try_block(); //todo: bug
///mailbox().try_block(); //todo: bug
}

auto type_impl() const noexcept -> const char* const final {
const char* type_impl() const noexcept final {
auto const *ptr = static_cast<const Actor*>(this);
return ptr->make_type();
}
Expand All @@ -88,12 +87,16 @@ namespace actor_zeta { namespace base {
} else {
supervisor()->scheduler()->enqueue(this);
}
break;
return true;
}
case detail::enqueue_result::success:
break;
case detail::enqueue_result::queue_closed:
break;
return true;
case detail::enqueue_result::queue_closed: {
return false ;
}
default: {
return false ;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion header/actor-zeta/base/supervisor_abstract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace actor_zeta { namespace base {
return self()->make_scheduler();
}

auto type_impl() const noexcept -> const char* const final {
const char* type_impl() const noexcept final {
auto const* ptr = static_cast<const Supervisor*>(this);
return ptr->make_type();
}
Expand Down
2 changes: 1 addition & 1 deletion header/actor-zeta/impl/actor/actor_abstract.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace actor_zeta { namespace base {
return enqueue(std::move(msg), nullptr);
}

auto actor_abstract::type() const noexcept -> const char* const {
const char* actor_abstract::type() const noexcept {
return type_impl();
}

Expand Down
7 changes: 4 additions & 3 deletions test/actor-id/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class dummy_supervisor final : public actor_zeta::cooperative_supervisor<dummy_s

void create() ;

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "dummy_supervisor";
}

Expand All @@ -56,10 +56,11 @@ class dummy_supervisor final : public actor_zeta::cooperative_supervisor<dummy_s
}
});
}
auto enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) -> void final {
bool enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) final {
{
set_current_message(std::move(msg));
behavior()(current_message());
return true;
}
}

Expand All @@ -76,7 +77,7 @@ class storage_t final : public actor_zeta::basic_actor<storage_t> {
: actor_zeta::basic_actor<storage_t>(ptr) {
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "storage";
}

Expand Down
9 changes: 5 additions & 4 deletions test/life-cycle/classes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class dummy_supervisor final
constructor_counter++;
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "dummy_supervisor";
}

Expand Down Expand Up @@ -92,10 +92,11 @@ class dummy_supervisor final
return supervisor_.back();
}

void enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) override {
bool enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) override {
enqueue_base_counter++;
set_current_message(std::move(msg));
behavior()(current_message());
return true;
}

private:
Expand Down Expand Up @@ -165,7 +166,7 @@ class storage_t final : public actor_zeta::basic_actor<storage_t> {
constructor_counter++;
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "storage";
}

Expand Down Expand Up @@ -319,7 +320,7 @@ class test_handlers final : public actor_zeta::basic_actor<test_handlers> {
init();
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "test_handlers";
}

Expand Down
12 changes: 7 additions & 5 deletions test/spawn/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class dummy_supervisor_sub final : public actor_zeta::cooperative_supervisor<dum
return executor_.get();
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "dummy_supervisor_sub";
}

Expand All @@ -67,11 +67,12 @@ class dummy_supervisor_sub final : public actor_zeta::cooperative_supervisor<dum
});
}

auto enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) -> void final {
bool enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) final {
{
set_current_message(std::move(msg));
behavior()(current_message());
}
return true;
}

private:
Expand Down Expand Up @@ -116,7 +117,7 @@ class dummy_supervisor final : public actor_zeta::cooperative_supervisor<dummy_s
resource());
}

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "dummy_supervisor";
}

Expand Down Expand Up @@ -146,11 +147,12 @@ class dummy_supervisor final : public actor_zeta::cooperative_supervisor<dummy_s
});
}

auto enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) -> void final {
bool enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) final {
{
set_current_message(std::move(msg));
behavior()(current_message());
}
return true;
}

private:
Expand All @@ -173,7 +175,7 @@ class storage_t final : public actor_zeta::basic_actor<storage_t> {
actor_counter++;
}

auto make_type() const noexcept -> const char* const {
auto make_type() const noexcept -> const char* {
return "storage";
}

Expand Down
5 changes: 3 additions & 2 deletions test/timer/classes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class supervisor_lite final : public actor_zeta::cooperative_supervisor<supervis

~supervisor_lite() override = default;

auto make_type() const noexcept -> const char* const {
const char* make_type() const noexcept {
return "supervisor_lite";
}

Expand All @@ -54,11 +54,12 @@ class supervisor_lite final : public actor_zeta::cooperative_supervisor<supervis
});
}

auto enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) -> void final {
bool enqueue_impl(actor_zeta::message_ptr msg, actor_zeta::execution_unit*) final {
{
set_current_message(std::move(msg));
behavior()(current_message());
}
return true;
}

private:
Expand Down

0 comments on commit a23a7c9

Please sign in to comment.