Is there any established mechanism for waiting on an insert into an ETS table if I want to use it for shared state?
I know mnesia support table events, I was thinking a similiar mechanism would be useful for plain ETS so that a process could wait until the data it needed was loaded. I think the only way to do this is to spin loop and continuously request the given key until it arrives, but that seems very inefficient. I would rather get a message callback. If I insert a process between mine and ETS I've just pushed the problem down the line.
The simplest workaround would be to start a gen_server
process and proxy all insert requests through it. You can then register callbacks by keeping them in the gen_server
state and call them when the inserted key matches the pattern. It could be even running in a separate application to allow for a dedicated supervisor.