gc-arena icon indicating copy to clipboard operation
gc-arena copied to clipboard

Make `Arena` conditionally Send if the root type is Send

Open kyren opened this issue 1 year ago • 7 comments

Also makes Gc<'static, T> Send, so that the Arena has a possibility of being send.

I am not totally sure on the soundness of this. It doesn't give any extra powers to any types other than the Arena type and Gc<'static, T>.

It shouldn't be possible to get into trouble with Gc at all, since you can't obtain a Gc<'static> in the first place (and even if you could safely, it could never be freed ~~so that's fine~~ it is totally not fine, and you totally could get a Gc<'static> which could make a !Sync type into a Sync one and I had to change the mutate signatures to prevent it).

You shouldn't be able to get in trouble with Arena, because it is always !Sync, and you won't be able to store anything !Send (other than Gc) inside of it.

A question I have is if there's some way to get in trouble with the projection of the root type, by applying the lifetime to a different type, to get a thing that mentions a type which is only Send if it is 'static (similar to Gc here), and have that be transmuted to 'static, but that can't be safe to do anyway since it would have to be an unsound lifetime transmute, since the 'gc is generative and can't be safely related to whatever type is being projected... I think?

Making Send Arenas would be heckin useful to me, because in ECS design, !Send types are generally always low level painful.

Anyway this is here to be discussed, feel free to crush my hopes and dreams.

kyren avatar May 12 '23 11:05 kyren