Conversation
|
|
||
| private final Path configurationPath; | ||
| private volatile Standalone.RustLib lib; | ||
| private volatile boolean running = false; |
There was a problem hiding this comment.
What are volatile properties and why are they needed here?
There was a problem hiding this comment.
volatile ensures cross-thread visibility, reads/write are done against main memory
PicoLimboRunner#run() and
PicoLimboRunner#stop() are called from different threads
| running = true; | ||
|
|
||
| String[] args = { | ||
| "pico_limbo_java_wrapper", |
There was a problem hiding this comment.
Why did you have to add pico_limbo_java_wrapper here?
There was a problem hiding this comment.
Uh, idk, it wasn't intended
| use std::sync::OnceLock; | ||
| use tokio_util::sync::CancellationToken; | ||
|
|
||
| static CANCEL_TOKEN: OnceLock<CancellationToken> = OnceLock::new(); |
There was a problem hiding this comment.
I don't really like static variables, but I think there aren't any way around it given we work with C library bindings?
There was a problem hiding this comment.
Hmm, I don't really know...
| () = token.cancelled() => { | ||
| tracing::info!("Shutdown signal received, stopping server..."); | ||
| } | ||
| } |
There was a problem hiding this comment.
I think there is a similar logic for handling SIGINT and SIGTERM signals, have you looked at how those two logic (signals and explicit cancellation) can be merged and if it is even possible?
This PR adds graceful shutdown support to the Java wrapper integration.
To fix this issues -> #58