Skip to content

Commit e4d1b56

Browse files
authored
Rust Port: MetaCall Handle implement Send+Sync and document it (#707)
* Rust Port: MetaCall Handle implement Send+Sync and document it * bump metacall version to 0.5.7
1 parent 4525bfa commit e4d1b56

2 files changed

Lines changed: 36 additions & 28 deletions

File tree

source/ports/rs_port/Cargo.toml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
[package]
2-
authors = ["Mahdi Sharifi <devraymondsh@gmail.com>", "Vicente Eduardo Ferrer Garcia <vic798@gmail.com>", "Swarnim Arun <swarnimarun11@gmail.com>"]
3-
description = "Call NodeJS, TypeScript, Python, C#, Ruby... functions from Rust (a Rust Port for MetaCall)."
4-
edition = "2021"
5-
keywords = ["ffi", "polyglot", "metacall", "inter-language", "polyglot-programming"]
6-
license = "Apache-2.0"
7-
name = "metacall"
8-
readme = "README.md"
9-
repository = "https://github.com/metacall/core/tree/develop/source/ports/rs_port"
10-
version = "0.5.6"
11-
12-
[lib]
13-
crate-type = ["lib"]
14-
doctest = false
15-
name = "metacall"
16-
path = "src/lib.rs"
17-
18-
[dependencies]
19-
metacall-inline = { version = "0.2.0", path = "./inline" }
20-
21-
[build-dependencies]
22-
metacall-sys = { version = "0.1.4", path = "./sys" }
23-
24-
[workspace]
25-
members = [
26-
"inline",
27-
"sys",
28-
]
1+
[package]
2+
authors = ["Mahdi Sharifi <devraymondsh@gmail.com>", "Vicente Eduardo Ferrer Garcia <vic798@gmail.com>", "Swarnim Arun <swarnimarun11@gmail.com>"]
3+
description = "Call NodeJS, TypeScript, Python, C#, Ruby... functions from Rust (a Rust Port for MetaCall)."
4+
edition = "2021"
5+
keywords = ["ffi", "polyglot", "metacall", "inter-language", "polyglot-programming"]
6+
license = "Apache-2.0"
7+
name = "metacall"
8+
readme = "README.md"
9+
repository = "https://github.com/metacall/core/tree/develop/source/ports/rs_port"
10+
version = "0.5.7"
11+
12+
[lib]
13+
crate-type = ["lib"]
14+
doctest = false
15+
name = "metacall"
16+
path = "src/lib.rs"
17+
18+
[dependencies]
19+
metacall-inline = { version = "0.2.0", path = "./inline" }
20+
21+
[build-dependencies]
22+
metacall-sys = { version = "0.1.4", path = "./sys" }
23+
24+
[workspace]
25+
members = [
26+
"inline",
27+
"sys",
28+
]

source/ports/rs_port/src/load.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,16 @@ impl fmt::Display for Tag {
6868
}
6969
}
7070

71+
/// A MetaCall Handle is basically a C Pointer, One can pass it to when loading a script
72+
/// (pass it to [[from_single_file]] for example) to keep the script in a local scope related to
73+
/// this specific [[Handle]]
74+
/// [[Handle]] implements Send + Sync traits because we are sure 100% and guarantee developers that
75+
/// it is thread-safe. The Handle is a read-only pointer so there is no problem here.
7176
pub struct Handle(*mut c_void);
7277

78+
unsafe impl Send for Handle {}
79+
unsafe impl Sync for Handle {}
80+
7381
impl Handle {
7482
pub fn new() -> Self {
7583
Self(null_mut())

0 commit comments

Comments
 (0)