forked from joey/godottest
add godot tokio license
This commit is contained in:
parent
9ad1f47e9d
commit
b3081de258
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -10,5 +10,6 @@
|
||||
"description": "Build (Debug)",
|
||||
"color": "default"
|
||||
}
|
||||
]
|
||||
],
|
||||
"VsCodeTaskButtons.showCounter": false
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
use godot::{classes::Engine, prelude::*};
|
||||
|
||||
use crate::tokio::AsyncRuntime;
|
||||
|
||||
mod tokio;
|
||||
mod runtime;
|
||||
|
||||
mod player;
|
||||
|
||||
@ -15,7 +13,10 @@ unsafe impl ExtensionLibrary for MyExtension {
|
||||
let mut engine = Engine::singleton();
|
||||
|
||||
// This is where we register our async runtime singleton.
|
||||
engine.register_singleton(AsyncRuntime::SINGLETON, &AsyncRuntime::new_alloc());
|
||||
engine.register_singleton(
|
||||
crate::runtime::tokio::AsyncRuntime::SINGLETON,
|
||||
&crate::runtime::tokio::AsyncRuntime::new_alloc(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,11 +25,14 @@ unsafe impl ExtensionLibrary for MyExtension {
|
||||
let mut engine = Engine::singleton();
|
||||
|
||||
// Here is where we free our async runtime singleton from memory.
|
||||
if let Some(async_singleton) = engine.get_singleton(AsyncRuntime::SINGLETON) {
|
||||
engine.unregister_singleton(AsyncRuntime::SINGLETON);
|
||||
if let Some(async_singleton) = engine.get_singleton(crate::runtime::tokio::AsyncRuntime::SINGLETON) {
|
||||
engine.unregister_singleton(crate::runtime::tokio::AsyncRuntime::SINGLETON);
|
||||
async_singleton.free();
|
||||
} else {
|
||||
godot_warn!("Failed to find & free singleton -> {}", AsyncRuntime::SINGLETON);
|
||||
godot_warn!(
|
||||
"Failed to find & free singleton -> {}",
|
||||
crate::runtime::tokio::AsyncRuntime::SINGLETON
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
rust/src/runtime/mod.rs
Normal file
1
rust/src/runtime/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod tokio;
|
||||
@ -1,3 +1,28 @@
|
||||
// Copied here because the original crate pins the wrong version of godot.
|
||||
// Source: https://github.com/2-3-5-41/godot_tokio/
|
||||
//
|
||||
// MIT License
|
||||
|
||||
// Copyright (c) 2025 2-3-5-41
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use std::{future::Future, rc::Rc};
|
||||
|
||||
use godot::{classes::Engine, prelude::*};
|
||||
Loading…
x
Reference in New Issue
Block a user