Repository: PistonDevelopers/dyon (language: rust)

Issue:
Disabling threading
Is there a way threading could be disabled for scripts? So that `go` does not work. I could imagine this working as a toggle on a Runtime or similarly.


Discussion / hints:
Do you want this as a run-time feature, that can be turned on or off, or is it sufficient as a Cargo feature?

I assume that there would be very little overhead from having a `bool` in `Runtime`.

PRs are welcome if you want to try this out yourself.
In my use-case it would be great for it to be a cargo feature, but I am not sure how much effort that would be? (Mainly so that I can statically make sure that this cannot happen.)

> PRs are welcome if you want to try this out yourself.

Gladly! Do you have any pointers to get started?

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 6c210de..5ec566e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,8 @@ default-features = false
 optional = true
 
 [features]
-default = ["debug_resolve", "http", "file"]
+default = ["debug_resolve", "http", "file", "threading"]
 debug_resolve = []
 http = ["reqwest"]
 file = []
+threading = []
diff --git a/src/lifetime/kind.rs b/src/lifetime/kind.rs
index bf68b97..4e253e2 100644
--- a/src/lifetime/kind.rs
+++ b/src/lifetime/kind.rs
@@ -192,7 +192,7 @@ impl Kind {
             "res" => Kind::Res,
             "ret_type" => Kind::RetType,
             "return_void" => Kind::ReturnVoid,
-            "go" => Kind::Go,
+            #[cfg(feature = "threading")] "go" => Kind::Go,
             "swizzle" => Kind::Swizzle,
             "sw0" => Kind::Sw0,
             "sw1" => Kind::Sw1,


Test patch: