Cancelable plugin system

i am trying to make an app with plugin system. user can click button on app to start and stop plugin running. i choose the libloading way for best performance and largest rust crate availability.

when user click start button, the host spawn new thread to load and start plugin function. but when user click stop button, running thread can't be simply canceled.

it seems i need to message plugin thread it's time to stop, and in plugin code, there must be listener on the message, that do simple panic on receive.

i don't know if it's the right way to go, willing to hear your advice.

If you run your plugin as a different process (I don't have experience with designing plugin systems - but this seems like an obvious choice, especially if you are directly calling plugin's code), then you can send SIGINT to it, and advise plugin creators to do cleanup in signal handler. Either way, plugin will be stopped, and it will have an opportunity to do cleanup.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.