use std::sync::Arc;
use super::service::{ServiceIdentity, ServiceInstanceId, ShutdownService};
use crate::io::{CompletionRing, StandardIoServer};
pub(super) struct RingService {
ring: Arc<dyn CompletionRing>,
instance: ServiceInstanceId,
}
impl RingService {
pub(super) fn new(ring: Arc<dyn CompletionRing>) -> Self {
Self {
ring,
instance: ServiceInstanceId::mint(),
}
}
pub(super) fn ring(&self) -> &Arc<dyn CompletionRing> {
&self.ring
}
pub(super) fn worker_thread_names(&self) -> Vec<String> {
self.ring.worker_thread_names()
}
pub(super) fn requested_worker_count(&self) -> usize {
self.ring.requested_worker_count()
}
}
impl ServiceIdentity for RingService {
fn instance_id(&self) -> ServiceInstanceId {
self.instance
}
}
impl ShutdownService for RingService {
fn shutdown(&self) {
self.ring.shutdown();
}
}
pub(super) struct StandardIoService {
server: StandardIoServer,
instance: ServiceInstanceId,
}
impl StandardIoService {
pub(super) fn new(server: StandardIoServer) -> Self {
Self {
server,
instance: ServiceInstanceId::mint(),
}
}
pub(super) fn server(&self) -> &StandardIoServer {
&self.server
}
}
impl ServiceIdentity for StandardIoService {
fn instance_id(&self) -> ServiceInstanceId {
self.instance
}
}
impl ShutdownService for StandardIoService {
fn shutdown(&self) {
self.server.shutdown();
}
}