Skip to content

Commit

Permalink
Add Send bound to graph operator node trait object
Browse files Browse the repository at this point in the history
This makes `Model` instances `Send`, which amongst other uses enables storing
them in PyO3 classes (that is, structs with the `#[pyclass]` annotation).

Relates to robertknight/ocrs#17.
  • Loading branch information
robertknight committed Feb 28, 2024
1 parent 92ce014 commit 56e9b58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct OperatorNode {
name: Option<String>,
inputs: Vec<Option<NodeId>>,
outputs: Vec<Option<NodeId>>,
operator: Box<dyn Operator + Sync>,
operator: Box<dyn Operator + Send + Sync>,
}

pub struct ValueNode {
Expand Down Expand Up @@ -250,7 +250,7 @@ impl Graph {
pub fn add_op(
&mut self,
name: Option<&str>,
op: Box<dyn Operator + Sync>,
op: Box<dyn Operator + Send + Sync>,
inputs: &[Option<NodeId>],
outputs: &[Option<NodeId>],
) -> NodeId {
Expand Down
2 changes: 1 addition & 1 deletion src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ fn array_from_iter<const N: usize, T: Default + Copy, I: Iterator<Item = T>>(
}

/// Result of deserializing an operator node from a model file.
pub type ReadOpResult = Result<Box<dyn Operator + Sync>, ReadOpError>;
pub type ReadOpResult = Result<Box<dyn Operator + Send + Sync>, ReadOpError>;

/// A function that deserializes an operator node.
pub type ReadOpFunction = dyn Fn(&OperatorNode) -> ReadOpResult;
Expand Down

0 comments on commit 56e9b58

Please sign in to comment.