pub mod traits;
mod shutdown;

#[cfg(windows)]
mod windows;
#[cfg(unix)]
mod unix;
#[cfg(target_os = "linux")]
mod linux;

pub use traits::{ProcessGroupManager, ProcessLifecycle};
pub use shutdown::graceful_shutdown_sync;
#[cfg(feature = "tokio")]
pub use shutdown::graceful_shutdown_async;

use std::sync::Arc;

/// Create the platform-appropriate ProcessGroupManager.
///
/// Call `init()` on the returned manager before use.
pub fn create_manager() -> Arc<dyn ProcessGroupManager> {
    #[cfg(windows)]
    { Arc::new(windows::WindowsProcessGroupManager::new()) }

    #[cfg(target_os = "linux")]
    { Arc::new(linux::LinuxProcessGroupManager::new()) }

    #[cfg(all(unix, not(target_os = "linux")))]
    { Arc::new(unix::UnixProcessGroupManager::new()) }
}
