Skip to content

Commit

Permalink
libaegisub: fix dispatch types
Browse files Browse the repository at this point in the history
  • Loading branch information
CoffeeFlux committed Nov 24, 2023
1 parent 51bdcf3 commit b899e07
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libaegisub/common/dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ namespace {
std::atomic<uint_fast32_t> threads_running;

class MainQueue final : public agi::dispatch::Queue {
void DoInvoke(agi::dispatch::Thunk thunk) override {
void DoInvoke(agi::dispatch::Thunk&& thunk) override {
invoke_main(thunk);
}
};

class BackgroundQueue final : public agi::dispatch::Queue {
void DoInvoke(agi::dispatch::Thunk thunk) override {
void DoInvoke(agi::dispatch::Thunk&& thunk) override {
service->post(thunk);
}
};

class SerialQueue final : public agi::dispatch::Queue {
boost::asio::io_service::strand strand;

void DoInvoke(agi::dispatch::Thunk thunk) override {
void DoInvoke(agi::dispatch::Thunk&& thunk) override {
strand.post(thunk);
}
public:
Expand Down Expand Up @@ -74,7 +74,7 @@ namespace {

namespace agi::dispatch {

void Init(std::function<void (Thunk)> invoke_main) {
void Init(std::function<void (Thunk)>&& invoke_main) {
static IOServiceThreadPool thread_pool;
::service = &thread_pool.io_service;
::invoke_main = invoke_main;
Expand All @@ -90,7 +90,7 @@ void Init(std::function<void (Thunk)> invoke_main) {
}
}

void Queue::Async(Thunk thunk) {
void Queue::Async(Thunk&& thunk) {
DoInvoke([=] {
try {
thunk();
Expand All @@ -102,7 +102,7 @@ void Queue::Async(Thunk thunk) {
});
}

void Queue::Sync(Thunk thunk) {
void Queue::Sync(Thunk&& thunk) {
std::mutex m;
std::condition_variable cv;
std::unique_lock<std::mutex> l(m);
Expand Down

0 comments on commit b899e07

Please sign in to comment.