hey look other platforms work

This commit is contained in:
Fleeym 2024-05-16 15:08:03 +03:00
parent 3f3b1430f5
commit 9bedf1bacc
2 changed files with 14 additions and 5 deletions
loader/include/Geode

View file

@ -147,6 +147,15 @@ namespace geode {
friend Mod* takeNextLoaderMod();
};
/**
* @brief Queues a function to run on the main thread
*
* @param func the function to queue
*/
inline GEODE_HIDDEN void queueInMainThread(ScheduledFunction func) {
Loader::get()->queueInMainThread(func);
}
/**
* @brief Take the next mod to load
*

View file

@ -249,7 +249,7 @@ namespace geode {
if (handle->m_status == Status::Pending) {
handle->m_status = Status::Finished;
handle->m_resultValue.emplace(std::move(value));
Loader::get()->queueInMainThread([handle, value = &*handle->m_resultValue]() mutable {
queueInMainThread([handle, value = &*handle->m_resultValue]() mutable {
// SAFETY: Task::all() depends on the lifetime of the value pointer
// being as long as the lifetime of the task itself
Event::createFinished(handle, value).post();
@ -262,7 +262,7 @@ namespace geode {
if (!handle) return;
std::unique_lock<std::recursive_mutex> lock(handle->m_mutex);
if (handle->m_status == Status::Pending) {
Loader::get()->queueInMainThread([handle, value = std::move(value)]() mutable {
queueInMainThread([handle, value = std::move(value)]() mutable {
Event::createProgressed(handle, &value).post();
});
}
@ -277,7 +277,7 @@ namespace geode {
if (!shallow && handle->m_extraData) {
handle->m_extraData->cancel();
}
Loader::get()->queueInMainThread([handle]() mutable {
queueInMainThread([handle]() mutable {
Event::createCancelled(handle).post();
std::unique_lock<std::recursive_mutex> lock(handle->m_mutex);
handle->m_finalEventPosted = true;
@ -668,14 +668,14 @@ namespace geode {
std::unique_lock<std::recursive_mutex> lock(m_handle->m_mutex);
if (m_handle->m_finalEventPosted) {
if (m_handle->m_status == Status::Finished) {
Loader::get()->queueInMainThread([handle = m_handle, listener = m_listener, value = &*m_handle->m_resultValue]() {
queueInMainThread([handle = m_handle, listener = m_listener, value = &*m_handle->m_resultValue]() {
auto ev = Event::createFinished(handle, value);
ev.m_for = listener;
ev.post();
});
}
else {
Loader::get()->queueInMainThread([handle = m_handle, listener = m_listener]() {
queueInMainThread([handle = m_handle, listener = m_listener]() {
auto ev = Event::createCancelled(handle);
ev.m_for = listener;
ev.post();