+4
-3
src/functions.rs
+4
-3
src/functions.rs
···
8
8
//! Functions that can be called by graph DSL files
9
9
10
10
use std::collections::HashMap;
11
+
use std::sync::Arc;
11
12
12
13
use crate::execution::error::ExecutionError;
13
14
use crate::graph::Graph;
···
85
86
/// A library of named functions.
86
87
#[derive(Default)]
87
88
pub struct Functions {
88
-
functions: HashMap<Identifier, Box<dyn Function>>,
89
+
functions: HashMap<Identifier, Arc<dyn Function + Send + Sync>>,
89
90
}
90
91
91
92
impl Functions {
···
141
142
/// Adds a new function to this library.
142
143
pub fn add<F>(&mut self, name: Identifier, function: F)
143
144
where
144
-
F: Function + 'static,
145
+
F: Function + Send + Sync + 'static,
145
146
{
146
-
self.functions.insert(name, Box::new(function));
147
+
self.functions.insert(name, Arc::new(function));
147
148
}
148
149
149
150
/// Calls a named function, returning an error if there is no function with that name.