1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
mod actor;
mod inner_store;
mod model;
mod queue;
mod queue_rwlock;
pub use actor::Actor;
pub use model::RwModel;
pub use queue::AQueue;
pub use queue_rwlock::RwQueue;
/// inner call wait ms throw time error
/// need on feature "tokio_time" or "async_std_time"
/// # tokio runtime:
/// ``` toml
/// aqueue = { version = "^1.2.10", features = ["tokio_time"] }
/// ```
/// # Example
/// ``` ignore
/// async fn test_unsafe_blocking(&self, name: String, gold: f64) -> Result<bool> {
/// inner_wait!(self, 30000, |_inner| async move { DB.insert_user(name, gold).await }).await?
/// }
/// ```
#[cfg(all(feature = "tokio_time", not(feature = "async_std_time")))]
#[macro_export]
macro_rules! inner_wait {
($actor:expr,$timeout:expr,$fun:expr) => {
tokio::time::timeout(std::time::Duration::from_millis($timeout), $actor.inner_call($fun))
};
}
/// inner call wait ms throw time error
/// need on feature "tokio_time" or "async_std_time"
/// # async_std runtime:
/// ``` toml
/// aqueue = { version = "^1.2.10", features = ["async_std_time"] }
/// ```
/// # Example
/// ``` ignore
/// async fn test_unsafe_blocking(&self, name: String, gold: f64) -> Result<bool> {
/// inner_wait!(self, 30000, |_inner| async move { DB.insert_user(name, gold).await }).await?
/// }
/// ```
#[cfg(all(feature = "async_std_time", not(feature = "tokio_time")))]
#[macro_export]
macro_rules! inner_wait {
($actor:expr,$timeout:expr,$fun:expr) => {
async_std::future::timeout(std::time::Duration::from_millis($timeout), $actor.inner_call($fun))
};
}
/// call_mut wait ms throw time error
/// need on feature "tokio_time" or "async_std_time"
/// # tokio runtime:
/// ``` toml
/// aqueue = { version = "^1.3.2", features = ["tokio_time"] }
/// ```
/// # Example
/// ``` ignore
/// async fn test_unsafe_blocking(&self, name: String, gold: f64) -> Result<bool> {
/// call_mut_wait!(self, 30000, |_inner| async move { DB.insert_user(name, gold).await }).await?
/// }
/// ```
#[cfg(all(feature = "tokio_time", not(feature = "async_std_time")))]
#[macro_export]
macro_rules! call_mut_wait {
($model:expr,$timeout:expr,$fun:expr) => {
tokio::time::timeout(std::time::Duration::from_millis($timeout), $model.call_mut($fun))
};
}
/// call_mut wait ms throw time error
/// need on feature "tokio_time" or "async_std_time"
/// # tokio runtime:
/// ``` toml
/// aqueue = { version = "^1.3.2", features = ["async_std_time"] }
/// ```
/// # Example
/// ``` ignore
/// async fn test_unsafe_blocking(&self, name: String, gold: f64) -> Result<bool> {
/// call_mut_wait!(self, 30000, |_inner| async move { DB.insert_user(name, gold).await }).await?
/// }
/// ```
#[cfg(all(feature = "async_std_time", not(feature = "tokio_time")))]
#[macro_export]
macro_rules! call_mut_wait {
($model:expr,$timeout:expr,$fun:expr) => {
async_std::future::timeout(std::time::Duration::from_millis($timeout), $model.call_mut($fun))
};
}
/// call wait ms throw time error
/// need on feature "tokio_time" or "async_std_time"
/// # tokio runtime:
/// ``` toml
/// aqueue = { version = "^1.3.2", features = ["tokio_time"] }
/// ```
/// # Example
/// ``` ignore
/// async fn test_unsafe_blocking(&self, name: String, gold: f64) -> Result<bool> {
/// call_wait!(self, 30000, |_inner| async move { DB.insert_user(name, gold).await }).await?
/// }
/// ```
#[cfg(all(feature = "tokio_time", not(feature = "async_std_time")))]
#[macro_export]
macro_rules! call_wait {
($model:expr,$timeout:expr,$fun:expr) => {
tokio::time::timeout(std::time::Duration::from_millis($timeout), $model.call($fun))
};
}
/// call wait ms throw time error
/// need on feature "tokio_time" or "async_std_time"
/// # tokio runtime:
/// ``` toml
/// aqueue = { version = "^1.3.2", features = ["async_std_time"] }
/// ```
/// # Example
/// ``` ignore
/// async fn test_unsafe_blocking(&self, name: String, gold: f64) -> Result<bool> {
/// call_wait!(self, 30000, |_inner| async move { DB.insert_user(name, gold).await }).await?
/// }
/// ```
#[cfg(all(feature = "async_std_time", not(feature = "tokio_time")))]
#[macro_export]
macro_rules! call_wait {
($model:expr,$timeout:expr,$fun:expr) => {
async_std::future::timeout(std::time::Duration::from_millis($timeout), $model.call($fun))
};
}