Lines Matching +full:queue +full:- +full:tick
151 /// pub fn new() -> Self {
219 /// Current scheduler tick.
220 tick: Cell<u8>,
222 /// State available from thread-local.
230 /// State available from the thread-local.
248 /// Remote run queue sender.
249 queue: Mutex<Option<VecDeque<task::Notified<Arc<Shared>>>>>, field
265 /// Local run queue sender and receiver.
332 pub fn spawn_local<F>(future: F) -> JoinHandle<F::Output>
342 pub(super) fn spawn_local_inner<F>(future: F, name: Option<&str>) -> JoinHandle<F::Output>
353 /// Initial queue capacity.
356 /// Max number of tasks to poll per tick.
359 /// How often it check the remote queue first.
374 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
381 pub fn new() -> LocalSet { in new()
385 tick: Cell::new(0), in new()
393 queue: Mutex::new(Some(VecDeque::with_capacity(INITIAL_CAPACITY))), in new()
410 pub fn enter(&self) -> LocalEnterGuard { in enter()
459 pub fn spawn_local<F>(&self, future: F) -> JoinHandle<F::Output> in spawn_local()
487 /// futures may not use [in-place blocking]. If a blocking call needs to be
527 /// [in-place blocking]: fn@crate::task::block_in_place
532 pub fn block_on<F>(&self, rt: &crate::runtime::Runtime, future: F) -> F::Output in block_on()
566 /// [awaiting the local set]: #awaiting-a-localset
567 pub async fn run_until<F>(&self, future: F) -> F::Output in run_until()
582 ) -> JoinHandle<F::Output> in spawn_named()
601 fn tick(&self) -> bool { in tick() method
618 // We have fully drained the queue of notified tasks, so the in tick()
628 fn next_task(&self) -> Option<task::LocalNotified<Arc<Shared>>> { in next_task()
629 let tick = self.tick.get(); in next_task() localVariable
630 self.tick.set(tick.wrapping_add(1)); in next_task()
632 let task = if tick % REMOTE_FIRST_INTERVAL == 0 { in next_task()
635 .queue in next_task()
638 .and_then(|queue| queue.pop_front()) in next_task()
644 .queue in next_task()
647 .and_then(|queue| queue.pop_front()) in next_task()
654 // therefore access the local run queue. in next_task()
659 fn pop_local(&self) -> Option<task::Notified<Arc<Shared>>> { in pop_local()
663 // therefore access the local run queue. in pop_local()
668 fn with<T>(&self, f: impl FnOnce() -> T) -> T { in with()
690 /// This method is like `with`, but it just calls `f` without setting the thread-local if that
692 fn with_if_possible<T>(&self, f: impl FnOnce() -> T) -> T { in with_if_possible()
751 /// tokio-rs/tokio#4516 for more details.
782 pub fn unhandled_panic(&mut self, behavior: crate::runtime::UnhandledPanic) -> &mut Self {
809 /// [unstable]: crate#unstable-features
811 pub fn id(&self) -> runtime::Id {
818 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
826 fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> { in poll()
830 if self.with(|| self.tick()) { in poll()
831 // If `tick` returns true, we need to notify the local future again: in poll()
832 // there are still tasks remaining in the run queue. in poll()
843 // futures in the run queue. Therefore, we can just return Pending in poll()
851 fn default() -> LocalSet { in default()
878 // the local queue in `Drop`, because the `LocalSet` itself is in drop()
889 // Take the queue from the Shared object to prevent pushing in drop()
891 let queue = self.context.shared.queue.lock().take().unwrap(); in drop() localVariable
892 for task in queue { in drop()
906 fn spawn<F>(&self, future: F, name: Option<&str>) -> JoinHandle<F::Output> in spawn()
936 fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> { in poll()
953 if me.local_set.tick() { in poll()
954 // If `tick` returns `true`, we need to notify the local future again: in poll()
955 // there are still tasks remaining in the run queue. in poll()
976 // wake to the local queue. in schedule()
989 // have to wake to the remote queue. in schedule()
991 // First, check whether the queue is still there (if not, the in schedule()
994 let mut lock = self.queue.lock(); in schedule()
996 if let Some(queue) = lock.as_mut() { in schedule()
997 queue.push_back(task); in schedule()
1006 fn ptr_eq(&self, other: &Shared) -> bool { in ptr_eq()
1012 // local run queue except from the thread that owns the `LocalSet`.
1016 fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { in release()
1043 _ => unreachable!("runtime core not set in CURRENT thread-local"),
1052 unsafe fn task_pop_front(&self) -> Option<task::Notified<Arc<Shared>>> { in task_pop_front()
1068 unsafe fn take_local_queue(&self) -> VecDeque<task::Notified<Arc<Shared>>> { in take_local_queue()
1076 unsafe fn task_remove(&self, task: &Task<Arc<Shared>>) -> Option<Task<Arc<Shared>>> { in task_remove()
1085 unsafe fn owned_is_empty(&self) -> bool { in owned_is_empty()
1096 ) -> task::LocalNotified<Arc<Shared>> { in assert_owner()
1114 // FreeBSD has some weirdness around thread-local destruction. in assert_called_from_owner_thread()
1119 // data, skip the assertion --- the `Drop` impl is not going to be in assert_called_from_owner_thread()
1124 "`LocalSet`'s local run queue must not be accessed by another thread!" in assert_called_from_owner_thread()
1137 // Does a `LocalSet` running on a current-thread runtime...basically work?
1158 // same thread, the task is woken to the localset's local queue rather than
1159 // its remote queue.
1197 "task should have been notified to the LocalSet's local queue" in wakes_to_local_queue()