`mkWeakIORef` finalizers running on the original bound thread (and/or "forkOS_Same" that's bound to the original OS thread)
Motivation
This proposal is needed for finalizers that run at GC, where the finalization is a C call that must run on the same OS thread as earlier C calls. (The standard "thread local" C API problem.)
(I know the "ideal" method is bracket syntax, but this is not always possible, e.g. when integrating with other libraries that are not bracket friendly.)
Proposal
An mkWeakIORef
finalizer is created from a bound thread. I want the ability to have it executed on the original bound thread (or at least a bound thread that is bound to the original OS thread).
Alternatively (in case it's easier to implement): Add a forkOS_Same
that (when called from a bound thread) spins off a bound thread that's bound to the same OS thread. With this feature (but without the mkWeakIORef
feature I mentioned earlier), I could hack together a solution at least: put a custom MVar
-based channel on the second thread, and use the existing mkWeakIORef
finalizer functionality to execute the C finalizer on the channel.