[MLton-user] FFI and pointer relocation
dherman at ccs.neu.edu
Mon Nov 26 08:50:48 PST 2007
If I pass a ref cell through the FFI to some C code which squirrels away
the pointer and updates it much later, will that always be safe? Or will
the GC potentially move the location of the ref cell?
I'm using this to pass a bool ref through the FFI as a sort of "mailbox"
to be notified whenever a particular event has occurred. Then the SML
code polls the mailbox during its event loop to check if it needs to
refresh some data (console window size) that becomes stale when the
event (console window resize) occurs. I'm not sure if this is the best
approach; the polling isn't expensive since I have a blocking loop
anyway, but maybe there's a more elegant solution to registering an
observer with the FFI.
More information about the MLton-user