Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Arc in call dylib callback #112

Merged
merged 1 commit into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit_runner"
version = "0.5.0-a13"
version = "0.5.0-a14"
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down Expand Up @@ -47,4 +47,4 @@ path = "src/bin/bundle_calcit.rs"


# [profile.release]
# debug = true
# debug = true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@calcit/procs",
"version": "0.5.0-a13",
"version": "0.5.0-a14",
"main": "./lib/calcit.procs.js",
"devDependencies": {
"@types/node": "^16.10.5",
Expand Down
5 changes: 3 additions & 2 deletions src/bin/injection/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::runner;
use cirru_edn::Edn;
use std::sync::Arc;
use std::thread;

use calcit_runner::{
Expand All @@ -11,7 +12,7 @@ use calcit_runner::{

/// FFI protocol types
type EdnFfi = fn(args: Vec<Edn>) -> Result<Edn, String>;
type EdnFfiFn = fn(args: Vec<Edn>, f: Box<dyn Fn(Edn) -> Edn>) -> Result<Edn, String>;
type EdnFfiFn = fn(args: Vec<Edn>, f: Arc<dyn Fn(Edn) -> Edn>) -> Result<Edn, String>;

pub fn inject_platform_apis() {
builtins::register_import_proc("&call-dylib-edn", call_dylib_edn);
Expand Down Expand Up @@ -196,7 +197,7 @@ pub fn call_dylib_edn_fn(xs: &CalcitItems) -> Result<Calcit, CalcitErr> {

match func(
ys.to_owned(),
Box::new(move |p: Edn| -> Edn {
Arc::new(move |p: Edn| -> Edn {
if let Calcit::Fn(_, def_ns, _, def_scope, args, body) = &callback {
let r = runner::run_fn(&im::vector![edn_to_calcit(&p)], def_scope, args, body, def_ns);
match r {
Expand Down
2 changes: 1 addition & 1 deletion ts-src/calcit.procs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// CALCIT VERSION
export const calcit_version = "0.5.0-a13";
export const calcit_version = "0.5.0-a14";

import { overwriteComparator, initTernaryTreeMap } from "@calcit/ternary-tree";
import { parse, ICirruNode } from "@cirru/parser.ts";
Expand Down