Index: Cargo.toml
==================================================================
--- Cargo.toml
+++ Cargo.toml
@@ -1,8 +1,8 @@
[package]
name = "ump-ng-server"
-version = "0.1.1"
+version = "0.1.2"
edition = "2021"
license = "0BSD"
categories = [ "concurrency", "asynchronous" ]
keywords = [ "channel", "threads", "sync", "message-passing" ]
repository = "https://repos.qrnch.tech/pub/ump-ng-server"
Index: src/lib.rs
==================================================================
--- src/lib.rs
+++ src/lib.rs
@@ -40,17 +40,25 @@
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
pub mod task;
pub mod thread;
-pub use ump_ng::{self, channel, Client, MsgType, ReplyContext, WeakClient};
+pub use ump_ng::{
+ self, channel, Client, MsgType, ReplyContext, Server, WeakClient
+};
-pub use thread::{spawn as spawn_thread, Handler as ThreadedHandler};
+pub use thread::{
+ spawn as spawn_thread, spawn_preinit as spawn_thread_preinit,
+ Handler as ThreadedHandler
+};
#[cfg(feature = "tokio")]
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
-pub use task::{spawn as spawn_task, Handler as AsyncHandler};
+pub use task::{
+ spawn as spawn_task, spawn_preinit as spawn_task_preinit,
+ Handler as AsyncHandler
+};
#[cfg(feature = "tokio")]
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
pub use async_trait::async_trait;
Index: src/task.rs
==================================================================
--- src/task.rs
+++ src/task.rs
@@ -2,11 +2,11 @@
use tokio::task::{self, JoinHandle};
use async_trait::async_trait;
-use super::{channel, Client, MsgType, ReplyContext};
+use super::{channel, Client, MsgType, ReplyContext, Server};
#[async_trait]
pub trait Handler
{
/// Optional initialization callback.
///
@@ -80,6 +80,42 @@
});
(client, jh)
}
+
+/// Spawn a task to run a pre-initialized handler.
+///
+/// It is assumed that the caller has initialized the handler, thus its
+/// `init()` method will not be called.
+pub fn spawn_preinit