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

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

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

anakrish
Copy link
Collaborator

With the arc feature, std::sync::Arc instead of non-atomic reference counters. This allows Engine, Value and other types to be shared across multiple threads. There would still need to be a mutex if a mut Engine needs to be shared across threads.

The arc feature is turned on by default.

The user can choose to:

  • Use arc and use atomic reference counters which might cost a bit of performance. This cost may not matter for many use-cases.
  • Disable arc and use single threaded reference counters. Engine and Value cannot be shared across threads. Values could be converted to json to pass between threads.

Also

  • add json API to set input and data.
  • Make Engine debug.

`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 <[email protected]>
Signed-off-by: Anand Krishnamoorthi <[email protected]>
@anakrish anakrish merged commit 53b990f into microsoft:main Feb 13, 2024
2 checks passed
@anakrish anakrish deleted the send branch February 13, 2024 18:23
@anakrish anakrish restored the send branch February 14, 2024 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant