arc feature to enable using Engine and other data structures from multiple threads (#142)

* `arc` feature to make engine usable from multiple threads.

`arc` is turned on by default. When enabled, std::sync::Arc
will be used instead of std::rc::Rc. The former makes regorus
types like Engine, Value, ast nodes etc Send, allowing for
usability from multiple threads.
Arc would add a performance overhead though since the reference
counting will now become atomic.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>

* Make engine and related types Debug

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>

* Input, Data as json. Evaluate bool queries.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>

---------

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-02-13 10:23:19 -08:00
committed by GitHub
parent 13eb06e4be
commit 53b990f97d
14 changed files with 96 additions and 24 deletions
+5 -3
View File
@@ -8,7 +8,9 @@ use core::str::CharIndices;
use std::convert::AsRef;
use std::path::Path;
use crate::value::Value;
use crate::Rc;
use crate::Value;
use anyhow::{anyhow, bail, Result};
#[derive(Clone)]
@@ -20,7 +22,7 @@ struct SourceInternal {
#[derive(Clone)]
pub struct Source {
src: std::rc::Rc<SourceInternal>,
src: Rc<SourceInternal>,
}
#[derive(Clone)]
@@ -108,7 +110,7 @@ impl Source {
lines.push((s, s));
}
Self {
src: std::rc::Rc::new(SourceInternal {
src: Rc::new(SourceInternal {
file,
contents,
lines,