C#C
C#2y ago
androidui

thread-safe concurrent task compilation system

https://gist.github.com/mgood7123/878b7c2988372838c51d11ee4fad84c3

how can i correctly set up locking and cancellation points for this?

the basic idea is that we call reload for each file to be compiled/recompiled, and we call invoke_callback which will invoke methods for any successfully compiled file

reload is called via FileSystemWatcher

invoke_method is called from user code (eg, our app)

reload launches a separate compilation task to avoid stalling the file watcher while compiling files

an attempt to reload during an active compilation should cancel the current compilation and start a new compilation

an attempt to unload during an active compilation should cancel the current compilation

upon a successful compilation, we execute a callback which is called in the compilation thread, outside of the file watcher thread

this callback should also handle cancellation if an unload or reload is triggered and we (the callback) have not yet finished

invoke_callback will invoke the specified callback for all succesfully compiled scripts, and should not handle unload and reload events as we expect the methods being called to correctly handle the cancellation event of the passed cancellation token

how can i correctly address all of the above ?
Gist
GitHub Gist: instantly share code, notes, and snippets.
Was this page helpful?