pub fn new(name: &'static str, adjustment_period: Duration) -> DeadlineQueue<T> {
        let queue = Rc::new(InnerQueue::new(adjustment_period));
        // We could always dispatch into the latency queue, but since that effectively
        // means putting requests in a different io_uring we'll avoid doing that
        // unless the process is very sensitive. Because of dead time it
        // wouldn't be a bad idea to even have a minimum here. But we'll just
        // document it and leave it to the user.
        let lat = {
            if adjustment_period < Duration::from_millis(100) {
                Latency::Matters(adjustment_period)
            } else {
                Latency::NotImportant
            }
        };

        let tq = crate::executor().create_task_queue(Shares::Dynamic(queue.clone()), lat, name);
        let (sender, receiver): (LocalSender<QueueItem<T>>, LocalReceiver<QueueItem<T>>) =
            local_channel::new_bounded(1);

        let (response_sender, responder): (LocalSender<T>, LocalReceiver<T>) =
            local_channel::new_bounded(1);

        let queue_weak = Rc::downgrade(&queue);

        let handle = crate::spawn_local_into(
            enclose! { (queue_weak) async move {
                let response = Rc::new(response_sender);
                let mut stream = receiver.stream();
                while let Some(request) = stream.next().await {
                    let res = request.action().await;
                    // now that we have executed the action, pop it from
                    // the queue. We must do it regardless of whether we succeeded.
                    //
                    // It is legal for the queue not to be present anymore in
                    // case the DeadlineQueue itself was destroyed after the action
                    // was done. But if it does exist we expect to be able to pop
                    // the element: so we unwrap() pop_front().
                    //
                    // Note that because this is a queue with concurrency of one we
                    // can safely pop_front(). If we ever do this with higher concurrency
                    // (very unlikely), then we need to move to a more complex data structure.
                    if let Some(queue) = queue_weak.upgrade() {
                        let mut queue = queue.queue.borrow_mut();
                        queue.pop_front().unwrap();
                    }
                    if response.send(res).await.is_err() {
                        warn!("receiver channel broken!");
                        break;
                    }
                }
            }},
            tq,
        )
        .unwrap()
        .detach();

        DeadlineQueue {
            tq,
            sender,
            responder,
            handle,
            queue,
        }
    }
/// Creates a new `DeadlineQueue` with a given `name` and `adjustment
/// period`
///
/// Internally the `DeadlineQueue` spawns a new task queue with dynamic
/// shares in which it will execute the tasks that were registered.
///
/// # Examples
/// ```
/// use glommio::{controllers::DeadlineQueue, LocalExecutor};
/// use std::time::Duration;
///
/// let ex = LocalExecutor::default();
///
/// ex.run(async {
///     DeadlineQueue::<usize>::new("example", Duration::from_millis(250));
/// });
/// ```


Internally the `DeadlineQueue` spawns a new task queue with dynamic
shares in which it will execute the tasks that were registered.
Internally the ` DeadlineQueue ` spawns a new task queue with dynamic shares in which it will execute the tasks that were registered .
pub fn new(name: &'static str, adjustment_period: Duration) -> DeadlineQueue<T> {
        let queue = Rc::new(InnerQueue::new(adjustment_period));
        // We could always dispatch into the latency queue, but since that effectively
        // means putting requests in a different io_uring we'll avoid doing that
        // unless the process is very sensitive. Because of dead time it
        // wouldn't be a bad idea to even have a minimum here. But we'll just
        // document it and leave it to the user.
        let lat = {
            if adjustment_period < Duration::from_millis(100) {
                Latency::Matters(adjustment_period)
            } else {
                Latency::NotImportant
            }
        };
        let tq = crate::executor().create_task_queue(Shares::Dynamic(queue.clone()), lat, name);
        let (sender, receiver): (LocalSender<QueueItem<T>>, LocalReceiver<QueueItem<T>>) =
            local_channel::new_bounded(1);
        let (response_sender, responder): (LocalSender<T>, LocalReceiver<T>) =
            local_channel::new_bounded(1);
        let queue_weak = Rc::downgrade(&queue);
        let handle = crate::spawn_local_into(
            enclose! { (queue_weak) async move {
                let response = Rc::new(response_sender);
                let mut stream = receiver.stream();
                while let Some(request) = stream.next().await {
                    let res = request.action().await;
                    // now that we have executed the action, pop it from
                    // the queue. We must do it regardless of whether we succeeded.
                    //
                    // It is legal for the queue not to be present anymore in
                    // case the DeadlineQueue itself was destroyed after the action
                    // was done. But if it does exist we expect to be able to pop
                    // the element: so we unwrap() pop_front().
                    //
                    // Note that because this is a queue with concurrency of one we
                    // can safely pop_front(). If we ever do this with higher concurrency
                    // (very unlikely), then we need to move to a more complex data structure.
                    if let Some(queue) = queue_weak.upgrade() {
                        let mut queue = queue.queue.borrow_mut();
                        queue.pop_front().unwrap();
                    }
                    if response.send(res).await.is_err() {
                        warn!("receiver channel broken!");
                        break;
                    }
                }
            }},
            tq,
        )
        .unwrap()
        .detach();
        DeadlineQueue {
            tq,
            sender,
            responder,
            handle,
            queue,
        }
    }
pub fn new ( name : & ' static str , adjustment_period : Duration ) -> DeadlineQueue < T > { let queue = Rc :: new ( InnerQueue :: new ( adjustment_period ) ) ; // We could always dispatch into the latency queue, but since that effectively // means putting requests in a different io_uring we'll avoid doing that // unless the process is very sensitive. Because of dead time it // wouldn't be a bad idea to even have a minimum here. But we'll just // document it and leave it to the user. let lat = { if adjustment_period < Duration :: from_millis ( 100 ) { Latency :: Matters ( adjustment_period ) } else { Latency :: NotImportant } } ; let tq = crate :: executor ( ) . create_task_queue ( Shares :: Dynamic ( queue . clone ( ) ) , lat , name ) ; let ( sender , receiver ) : ( LocalSender < QueueItem < T > > , LocalReceiver < QueueItem < T > > ) = local_channel :: new_bounded ( 1 ) ; let ( response_sender , responder ) : ( LocalSender < T > , LocalReceiver < T > ) = local_channel :: new_bounded ( 1 ) ; let queue_weak = Rc :: downgrade ( & queue ) ; let handle = crate :: spawn_local_into ( enclose ! { ( queue_weak ) async move { let response Rc new ( response_sender ) let mut stream receiver stream ( ) while let Some ( request ) stream next ( ) await { let res request action ( ) await // now that we have executed the action, pop it from // the queue. We must do it regardless of whether we succeeded. // It is legal for the queue not to be present anymore in // case the DeadlineQueue itself was destroyed after the action // was done. But if it does exist we expect to be able to pop // the element: so we unwrap() pop_front(). // Note that because this is a queue with concurrency of one we // can safely pop_front(). If we ever do this with higher concurrency // (very unlikely), then we need to move to a more complex data structure. if let Some ( queue ) queue_weak upgrade ( ) { let mut queue queue queue borrow_mut ( ) queue pop_front ( ) unwrap ( ) } if response send ( res ) await is_err ( ) { warn ( " " ) break } } } } , tq , ) . unwrap ( ) . detach ( ) ; DeadlineQueue { tq , sender , responder , handle , queue , } }
Creates a new `DeadlineQueue` with a given `name` and `adjustment
period`
Creates a new ` DeadlineQueue ` with a given ` name ` and ` adjustment period `
name
&'static str
adjustment_period
Duration
name
&'static str
adjustment_period
Duration
examples
```
use glommio::{controllers::DeadlineQueue, LocalExecutor};
use std::time::Duration.

let ex = LocalExecutor::default().

ex.run(async {
DeadlineQueue::::new("example", Duration::from_millis(250));
});
```
` ` ` use glommio :: { controllers :: DeadlineQueue LocalExecutor } ; use std :: time :: Duration . let ex = LocalExecutor :: default () . ex . run ( async { DeadlineQueue :::: new ( " example " Duration :: from_millis ( 250 )) ; } ) ; ` ` `