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`.
This commit is contained in:
David Cole 2021-11-23 18:59:09 +13:00 committed by GitHub
parent c12dde1866
commit 8d37afc510
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,7 +85,10 @@ pub struct ClassMetadata<T> {
handlers: MaybeUninit<ZendObjectHandlers>, handlers: MaybeUninit<ZendObjectHandlers>,
ce: AtomicPtr<ClassEntry>, ce: AtomicPtr<ClassEntry>,
phantom: PhantomData<T>, // `AtomicPtr` is used here because it is `Send + Sync`.
// fn() -> T could have been used but that is incompatible with const fns at
// the moment.
phantom: PhantomData<AtomicPtr<T>>,
} }
impl<T> ClassMetadata<T> { impl<T> ClassMetadata<T> {