Update queueInMainThread to be movable

This commit is contained in:
altalk23 2024-06-03 23:21:17 +03:00
parent e52b488d0d
commit 0c35a92ece
6 changed files with 9 additions and 12 deletions

View file

@ -266,9 +266,6 @@ target_include_directories(GeodeBindings PUBLIC
target_link_directories(GeodeBindings PUBLIC ${GEODE_LOADER_PATH}/include/link)
target_link_libraries(GeodeBindings PUBLIC fmt TulipHookInclude mat-json)
target_link_libraries(${PROJECT_NAME} INTERFACE GeodeBindings)
if (${GEODE_REVERT_TODO_RETURN})
target_compile_definitions(GeodeBindings PUBLIC GEODE_REVERT_TODO_RETURN)
endif()
if (NOT EXISTS ${GEODE_BIN_PATH})
file(MAKE_DIRECTORY ${GEODE_BIN_PATH})

View file

@ -140,7 +140,7 @@ namespace geode {
return value.as<T>();
}
void queueInMainThread(ScheduledFunction func);
void queueInMainThread(ScheduledFunction&& func);
/**
* Returns the current game version.
@ -158,8 +158,8 @@ namespace geode {
*
* @param func the function to queue
*/
inline GEODE_HIDDEN void queueInMainThread(ScheduledFunction func) {
Loader::get()->queueInMainThread(func);
inline GEODE_HIDDEN void queueInMainThread(ScheduledFunction&& func) {
Loader::get()->queueInMainThread(std::forward<ScheduledFunction>(func));
}
/**

View file

@ -19,7 +19,7 @@
using DerivedFuncType = decltype(Resolve<__VA_ARGS__>::func(&Derived::FunctionName_)); \
if constexpr (different) { \
static auto address = AddressInline_; \
static_assert(GEODE_REVERT_TODO_RETURN || \
static_assert( \
!different || !std::is_same_v<typename ReturnType<BaseFuncType>::type, TodoReturn>, \
"Function" #ClassName_ "::" #FunctionName_ " has a TodoReturn type, " \
"please fix it by editing the bindings." \

View file

@ -93,8 +93,8 @@ std::vector<LoadProblem> Loader::getRecommendations() const {
return result;
}
void Loader::queueInMainThread(ScheduledFunction func) {
return m_impl->queueInMainThread(std::move(func));
void Loader::queueInMainThread(ScheduledFunction&& func) {
return m_impl->queueInMainThread(std::forward<ScheduledFunction>(func));
}
std::string Loader::getGameVersion() {

View file

@ -802,9 +802,9 @@ bool Loader::Impl::loadHooks() {
return !hadErrors;
}
void Loader::Impl::queueInMainThread(const ScheduledFunction& func) {
void Loader::Impl::queueInMainThread(ScheduledFunction&& func) {
std::lock_guard<std::mutex> lock(m_mainThreadMutex);
m_mainThreadQueue.push_back(func);
m_mainThreadQueue.push_back(std::forward<ScheduledFunction>(func));
}
void Loader::Impl::executeMainThreadQueue() {

View file

@ -122,7 +122,7 @@ namespace geode {
void updateResources(bool forceReload);
void queueInMainThread(const ScheduledFunction& func);
void queueInMainThread(ScheduledFunction&& func);
void executeMainThreadQueue();
bool isReadyToHook() const;