mirror of
https://github.com/bdwgc/bdwgc-rust.git
synced 2026-10-26 17:53:18 -06:00
cb1b94cf6fb8791c4c084fdcecc9dfd8fcebe028
Bumps [rust-lang/crates-io-auth-action](https://github.com/rust-lang/crates-io-auth-action) from 1.0.5 to 1.0.6. - [Release notes](https://github.com/rust-lang/crates-io-auth-action/releases) - [Commits](https://github.com/rust-lang/crates-io-auth-action/compare/c6f97d42243bad5fab37ca0427f495c86d5b1a18...3268eb413133e2960fa4ae0e963ca76380c54cd9) --- updated-dependencies: - dependency-name: rust-lang/crates-io-auth-action dependency-version: 1.0.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
bdwgc-rust
GlobalAlloc implementation for bdwgc, the conservative garbage collector.
This crate is for use cases in which developers need to integrate bdwgc into their programs written in Rust (e.g. writing a runtime library in Rust for their own programming language whose GC is done by bdwgc.)
The raw bindings to the C API of bdwgc that this crate is built on are available as the bdwgc-alloc-sys crate.
Usage
use bdwgc_alloc::Allocator;
use std::thread::spawn;
#[global_allocator]
static GLOBAL_ALLOCATOR: Allocator = Allocator;
fn main() {
unsafe { Allocator::initialize() }
// Unreachable objects are collected automatically.
Box::leak(Box::new([0u8; 256]));
// Threads other than a main thread must be registered to a collector before allocation.
spawn(|| {
unsafe { Allocator::register_current_thread() }.unwrap();
Box::leak(Box::new([0u8; 256]));
unsafe { Allocator::unregister_current_thread() }
})
.join()
.unwrap();
}
By default bdwgc is built with autotools. To build with cmake, enable the cmake feature:
cargo build --no-default-features --features cmake
License
Languages
Rust
100%