Skip to content

Commit

Permalink
change collectable to trace
Browse files Browse the repository at this point in the history
  • Loading branch information
claytonwramsey committed Aug 27, 2024
1 parent 11d890a commit 64e6365
Show file tree
Hide file tree
Showing 17 changed files with 343 additions and 339 deletions.
38 changes: 22 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,58 @@
# `dumpster` Changelog

## 1.0.0

### Breaking changes

- Rename `Collectable` to `Trace`.

## 0.2.1

### New features

- Implement `Collectable` for `std::any::TypeId`.
- Implement `Collectable` for `std::any::TypeId`.

## 0.2.0

### New features

- Added `Gc::as_ptr`.
- Added `Gc::ptr_eq`.
- Implemented `PartialEq` and `Eq` for garbage collected pointers.
- Added `Gc::as_ptr`.
- Added `Gc::ptr_eq`.
- Implemented `PartialEq` and `Eq` for garbage collected pointers.

### Other

- Changed license from GNU GPLv3 or later to MPL 2.0.
- Allocations which do not contain `Gc`s will simply be reference counted.
- Changed license from GNU GPLv3 or later to MPL 2.0.
- Allocations which do not contain `Gc`s will simply be reference counted.

## 0.1.2

### New features

- Implement `Collectable` for `OnceCell`, `HashMap`, and `BTreeMap`.
- Add `try_clone` and `try_deref` to `unsync::Gc` and `sync::Gc`.
- Make dereferencing `Gc` only panic on truly-dead `Gc`s.
- Implement `Collectable` for `OnceCell`, `HashMap`, and `BTreeMap`.
- Add `try_clone` and `try_deref` to `unsync::Gc` and `sync::Gc`.
- Make dereferencing `Gc` only panic on truly-dead `Gc`s.

### Bugfixes

- Prevent dead `Gc`s from escaping their `Drop` implementation, potentially causing UAFs.
- Use fully-qualified name for `Result` in derive macro, preventing some bugs.
- Prevent dead `Gc`s from escaping their `Drop` implementation, potentially causing UAFs.
- Use fully-qualified name for `Result` in derive macro, preventing some bugs.

### Other

- Improve performance in `unsync` by using `parking_lot` for concurrency primitives.
- Improve documentation of panicking behavior in `Gc`.
- Fix spelling mistakes in documentation.
- Improve performance in `unsync` by using `parking_lot` for concurrency primitives.
- Improve documentation of panicking behavior in `Gc`.
- Fix spelling mistakes in documentation.

## 0.1.1

### Bugfixes

- Prevent possible UAFs caused by accessing `Gc`s during `Drop` impls by panicking.
- Prevent possible UAFs caused by accessing `Gc`s during `Drop` impls by panicking.

### Other

- Fix spelling mistakes in documentation.
- Fix spelling mistakes in documentation.

## 0.1.0

Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ It detects unreachable allocations and automatically frees them.

In short, `dumpster` offers a great mix of usability, performance, and flexibility.

- `dumpster`'s API is a drop-in replacement for `std`'s reference-counted shared allocations
(`Rc` and `Arc`).
- It's very performant and has builtin implementations of both thread-local and concurrent
garbage collection.
- There are no restrictions on the reference structure within a garbage-collected allocation
(references may point in any way you like).
- It's trivial to make a custom type collectable using the provided derive macros.
- You can even store `?Sized` data in a garbage-collected pointer!
- `dumpster`'s API is a drop-in replacement for `std`'s reference-counted shared allocations
(`Rc` and `Arc`).
- It's very performant and has builtin implementations of both thread-local and concurrent
garbage collection.
- There are no restrictions on the reference structure within a garbage-collected allocation
(references may point in any way you like).
- It's trivial to make a custom type Trace using the provided derive macros.
- You can even store `?Sized` data in a garbage-collected pointer!

## How it works

Expand All @@ -34,14 +34,14 @@ garbage collector in the module `unsync`, and one thread-safe garbage collector
`sync`.
These garbage collectors can be safely mixed and matched.

This library also comes with a derive macro for creating custom collectable types.
This library also comes with a derive macro for creating custom Trace types.

## Examples

```rust
use dumpster::{Collectable, unsync::Gc};
use dumpster::{Trace, unsync::Gc};

#[derive(Collectable)]
#[derive(Trace)]
struct Foo {
ptr: RefCell<Option<Gc<Foo>>>,
}
Expand All @@ -59,8 +59,8 @@ let foo = Gc::new(Foo {
// If we had used `Rc` instead of `Gc`, this would have caused a memory leak.
drop(foo);

// Trigger a collection.
// This isn't necessary, but it guarantees that `foo` will be collected immediately (instead of
// Trigger a collection.
// This isn't necessary, but it guarantees that `foo` will be collected immediately (instead of
// later).
dumpster::unsync::collect();
```
Expand All @@ -71,22 +71,22 @@ To install, simply add `dumpster` as a dependency to your project.

```toml
[dependencies]
dumpster = "0.2.1"
dumpster = "1.0.0"
```

## Optional features

`dumpster` has two optional features: `derive` and `coerce-unsized`.

`derive` is enabled by default.
It enables the derive macro for `Collectable`, which makes it easy for users to implement their
own collectable types.
It enables the derive macro for `Trace`, which makes it easy for users to implement their
own Trace types.

```rust
use dumpster::{unsync::Gc, Collectable};
use dumpster::{unsync::Gc, Trace};
use std::cell::RefCell;

#[derive(Collectable)] // no manual implementation required
#[derive(Trace)] // no manual implementation required
struct Foo(RefCell<Option<Gc<Foo>>>);

let my_foo = Gc::new(Foo(RefCell::new(None)));
Expand All @@ -110,7 +110,7 @@ To use `coerce-unsized`, edit your installation to `Cargo.toml` to include the f

```toml
[dependencies]
dumpster = { version = "0.2.1", features = ["coerce-unsized"]}
dumpster = { version = "1.0.0", features = ["coerce-unsized"]}
```

## License
Expand Down
4 changes: 2 additions & 2 deletions dumpster/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dumpster"
version = "0.2.1"
version = "1.0.0"
edition = "2021"
license = "MPL-2.0"
authors = ["Clayton Ramsey"]
Expand All @@ -17,7 +17,7 @@ derive = ["dep:dumpster_derive"]

[dependencies]
parking_lot = "0.12"
dumpster_derive = { version = "0.2.0", path = "../dumpster_derive", optional = true }
dumpster_derive = { version = "1.0.0", path = "../dumpster_derive", optional = true }

[dev-dependencies]
fastrand = "2.0.0"
Expand Down
Loading

0 comments on commit 64e6365

Please sign in to comment.