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

Fix rust send sync #259

Merged
merged 3 commits into from
Dec 23, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,7 @@ jobs:
# run all tests with feature download-bridgestan-src
cargo test --verbose --all-features
cargo test --verbose model_compiling -- --ignored
- name: Check semver for rust interface
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
manifest-path: ./rust/Cargo.toml
4 changes: 4 additions & 0 deletions rust/src/bs_safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ pub struct StanLibrary {
id: u64,
}

// Stan libraries are thread safe.
unsafe impl Send for StanLibrary {}
unsafe impl Sync for StanLibrary {}

// To work around a bug where unloading a library
// can lead to deadlocks.
//
Expand Down
6 changes: 3 additions & 3 deletions src/bridgestan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "callback_stream.hpp"
#include <sstream>

int bs_major_version = BRIDGESTAN_MAJOR;
int bs_minor_version = BRIDGESTAN_MINOR;
int bs_patch_version = BRIDGESTAN_PATCH;
const int bs_major_version = BRIDGESTAN_MAJOR;
const int bs_minor_version = BRIDGESTAN_MINOR;
const int bs_patch_version = BRIDGESTAN_PATCH;

bs_model* bs_model_construct(const char* data, unsigned int seed,
char** error_msg) {
Expand Down
6 changes: 3 additions & 3 deletions src/bridgestan.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ typedef void (*STREAM_CALLBACK)(const char* data, size_t size);
* @note These were not available pre-2.0.0, so their absence
* implies the library is in the 1.0.x series
*/
BS_PUBLIC extern int bs_major_version;
BS_PUBLIC extern int bs_minor_version;
BS_PUBLIC extern int bs_patch_version;
BS_PUBLIC extern const int bs_major_version;
BS_PUBLIC extern const int bs_minor_version;
BS_PUBLIC extern const int bs_patch_version;

/**
* Construct an instance of a model wrapper.
Expand Down
Loading