-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include "merian/vk/sync/semaphore_timeline.hpp" | ||
|
||
namespace merian { | ||
|
||
/* A Dispatches callbacks after dependent on a semaphore value. | ||
* | ||
* The callbacks run on the contexts' thread pool. | ||
*/ | ||
class SyncDispatcher { | ||
|
||
public: | ||
SyncDispatcher(const ContextHandle& context) : context(context), interrupt_semaphore(TimelineSemaphore::create(context)) { | ||
dispatcher_thread = std::thread([](){ | ||
SPDLOG_DEBUG("dispatcher thread started"); | ||
|
||
SPDLOG_DEBUG("dispatcher thread quitting"); | ||
|
||
}); | ||
|
||
|
||
} | ||
|
||
~SyncDispatcher() { | ||
SPDLOG_DEBUG("stopping dispatcher thread."); | ||
stop.store(true); | ||
interrupt_semaphore->signal(interrupt_wait_value); | ||
dispatcher_thread.join(); | ||
} | ||
|
||
private: | ||
const ContextHandle context; | ||
const TimelineSemaphoreHandle interrupt_semaphore; | ||
std::thread dispatcher_thread; | ||
std::atomic_bool stop = false; | ||
std::atomic<uint64_t> interrupt_wait_value = 1; | ||
}; | ||
|
||
} // namespace merian |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters