Skip to content

Commit

Permalink
Add group registration to frame processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ASxa86 committed Jun 17, 2024
1 parent 1cd4e89 commit 43ef244
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
10 changes: 8 additions & 2 deletions include/aspire/core/Kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ namespace aspire::core
class ASPIRE_CORE_EXPORT Kernel : public Object
{
public:
enum class FrameGroup : sigslot::group_id
{
Service,
Object
};

static constexpr std::chrono::milliseconds FrameFixedRate{10};
static auto Instance() -> Kernel*;

Expand All @@ -23,8 +29,8 @@ namespace aspire::core

auto sendEvent(Event& x, Object* receiver) -> void;
auto queueEvent(std::unique_ptr<Event> x, Object* receiver) -> void;
auto onFrame(std::function<void()> x) -> sigslot::connection;
auto onFrameFixed(std::function<void()> x) -> sigslot::connection;
auto onFrame(std::function<void()> x, FrameGroup group) -> sigslot::connection;
auto onFrameFixed(std::function<void()> x, FrameGroup group) -> sigslot::connection;

auto run() -> int;
auto quit() -> void;
Expand Down
4 changes: 2 additions & 2 deletions include/aspire/core/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ namespace aspire::core
auto onChildAdded(std::function<void(Object*)> x) -> sigslot::connection;
auto onChildRemoved(std::function<void(Object*)> x) -> sigslot::connection;
auto onStartup(std::function<void()> x) -> sigslot::connection;
auto onFrame(std::function<void()> x) -> sigslot::connection;
auto onFrameFixed(std::function<void()> x) -> sigslot::connection;
auto onFrame(std::function<void()> x) const -> sigslot::connection;
auto onFrameFixed(std::function<void()> x) const -> sigslot::connection;

private:
struct Impl;
Expand Down
8 changes: 4 additions & 4 deletions src/core/Kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ auto Kernel::queueEvent(std::unique_ptr<Event> x, Object* receiver) -> void
this->pimpl->events.emplace_back(std::move(x), receiver);
}

auto Kernel::onFrame(std::function<void()> x) -> sigslot::connection
auto Kernel::onFrame(std::function<void()> x, FrameGroup group) -> sigslot::connection
{
return this->pimpl->frame.connect(std::move(x));
return this->pimpl->frame.connect(std::move(x), static_cast<sigslot::group_id>(group));
}

auto Kernel::onFrameFixed(std::function<void()> x) -> sigslot::connection
auto Kernel::onFrameFixed(std::function<void()> x, FrameGroup group) -> sigslot::connection
{
return this->pimpl->frameFixed.connect(std::move(x));
return this->pimpl->frameFixed.connect(std::move(x), static_cast<sigslot::group_id>(group));
}

auto Kernel::run() -> int
Expand Down
8 changes: 4 additions & 4 deletions src/core/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ auto Object::onStartup(std::function<void()> x) -> sigslot::connection
return this->pimpl->startup.connect(std::move(x));
}

auto Object::onFrame(std::function<void()> x) -> sigslot::connection
auto Object::onFrame(std::function<void()> x) const -> sigslot::connection
{
return Kernel::Instance()->onFrame(std::move(x));
return Kernel::Instance()->onFrame(std::move(x), Kernel::FrameGroup::Object);
}

auto Object::onFrameFixed(std::function<void()> x) -> sigslot::connection
auto Object::onFrameFixed(std::function<void()> x) const -> sigslot::connection
{
return Kernel::Instance()->onFrameFixed(std::move(x));
return Kernel::Instance()->onFrameFixed(std::move(x), Kernel::FrameGroup::Object);
}

0 comments on commit 43ef244

Please sign in to comment.