ChrisPenner / rasa

Extremely modular text editor built in Haskell
GNU General Public License v3.0
616 stars 42 forks source link

dispatch events from other threads (forkIO) #23

Closed clojj closed 7 years ago

clojj commented 7 years ago

"... Extensions may also dispatch any kind of event at any time which other extensions may listen for."

Is it save to dispatchEvent from other threads ?

Say in the Main.hs you forkIO before starting the rasa event-loop. Then (communicating via MVar's) at some point that forked thread wants to deliver a rasa-event. Is that safe ?

ChrisPenner commented 7 years ago

I believe I answered most of this question in the other thread; but as for dispatching events asynchronously, it isn't supported as part of a doAsync call; but if your extension has sporadic events it would like to fire you can register an eventProvider which will do this for you.

What sort of events are you planning to dispatch asynchronously?

It would be possible to build that functionality in (via Pipes like this PR); but I'd have to revamp that PR as it's too out of date to merge now.