mirror of
https://github.com/godotengine/godot.git
synced 2025-10-22 09:23:40 +00:00
Merge pull request #10060 from endragor/nativescript-frame
Forward frame call to GDNative libraries
This commit is contained in:
commit
056b5f9e56
3 changed files with 32 additions and 44 deletions
|
@ -1052,9 +1052,21 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef NO_THREADS
|
||||
void NativeScriptLanguage::call_libraries_cb(const StringName &name) {
|
||||
// library_gdnatives is modified only from the main thread, so it's safe not to use mutex here
|
||||
for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) {
|
||||
L->get()->call_native_raw(
|
||||
_noarg_call_type,
|
||||
name,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeScriptLanguage::frame() {
|
||||
#ifndef NO_THREADS
|
||||
if (has_objects_to_register) {
|
||||
MutexLock lock(mutex);
|
||||
for (Set<Ref<GDNativeLibrary> >::Element *L = libs_to_init.front(); L; L = L->next()) {
|
||||
|
@ -1067,44 +1079,18 @@ void NativeScriptLanguage::frame() {
|
|||
scripts_to_register.clear();
|
||||
has_objects_to_register = false;
|
||||
}
|
||||
#endif
|
||||
call_libraries_cb(_frame_call_name);
|
||||
}
|
||||
|
||||
#ifndef NO_THREADS
|
||||
|
||||
void NativeScriptLanguage::thread_enter() {
|
||||
Vector<Ref<GDNative> > libs;
|
||||
{
|
||||
MutexLock lock(mutex);
|
||||
for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) {
|
||||
libs.push_back(L->get());
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < libs.size(); ++i) {
|
||||
libs[i]->call_native_raw(
|
||||
_thread_cb_call_type,
|
||||
_thread_enter_call_name,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
call_libraries_cb(_thread_enter_call_name);
|
||||
}
|
||||
|
||||
void NativeScriptLanguage::thread_exit() {
|
||||
Vector<Ref<GDNative> > libs;
|
||||
{
|
||||
MutexLock lock(mutex);
|
||||
for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) {
|
||||
libs.push_back(L->get());
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < libs.size(); ++i) {
|
||||
libs[i]->call_native_raw(
|
||||
_thread_cb_call_type,
|
||||
_thread_exit_call_name,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
call_libraries_cb(_thread_exit_call_name);
|
||||
}
|
||||
|
||||
#endif // NO_THREADS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue