Skip to content

Commit 8d37afc

Browse files
Make ClassMetadata: Send + Sync (#111)
This wasn't the case because of `PhantomData<T>` inside the metadata. Replacing this with `PhantomData<AtomicPtr<T>>` ensures that the metadata will always be `Send + Sync`.
1 parent c12dde1 commit 8d37afc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/class.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ pub struct ClassMetadata<T> {
8585
handlers: MaybeUninit<ZendObjectHandlers>,
8686
ce: AtomicPtr<ClassEntry>,
8787

88-
phantom: PhantomData<T>,
88+
// `AtomicPtr` is used here because it is `Send + Sync`.
89+
// fn() -> T could have been used but that is incompatible with const fns at
90+
// the moment.
91+
phantom: PhantomData<AtomicPtr<T>>,
8992
}
9093

9194
impl<T> ClassMetadata<T> {

0 commit comments

Comments
 (0)