mod.rs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. use slab::Slab;
  2. use std::sync::Arc;
  3. use crate::ScopeId;
  4. mod bumpslab;
  5. mod handle;
  6. mod suspense;
  7. mod task;
  8. mod wait;
  9. mod waker;
  10. pub use handle::*;
  11. pub use suspense::*;
  12. pub use task::*;
  13. pub use waker::RcWake;
  14. /// The type of message that can be sent to the scheduler.
  15. ///
  16. /// These messages control how the scheduler will process updates to the UI.
  17. #[derive(Debug)]
  18. pub enum SchedulerMsg {
  19. /// Events from the Renderer
  20. Event,
  21. /// Immediate updates from Components that mark them as dirty
  22. Immediate(ScopeId),
  23. /// Mark all components as dirty and update them
  24. DirtyAll,
  25. /// A task has woken and needs to be progressed
  26. TaskNotified(TaskId),
  27. /// A task has woken and needs to be progressed
  28. SuspenseNotified(SuspenseId),
  29. }
  30. pub struct Scheduler {
  31. rx: futures_channel::mpsc::UnboundedReceiver<SchedulerMsg>,
  32. ready_suspense: Vec<ScopeId>,
  33. pub handle: SchedulerHandle,
  34. }
  35. impl Scheduler {
  36. pub fn new() -> Self {
  37. let (tx, rx) = futures_channel::mpsc::unbounded();
  38. Self {
  39. rx,
  40. handle: SchedulerHandle::new(tx),
  41. ready_suspense: Default::default(),
  42. }
  43. }
  44. /// Waits for a future to complete that marks the virtualdom as dirty
  45. ///
  46. /// Not all messages will mark a virtualdom as dirty, so this waits for a message that has side-effects that do
  47. pub fn wait_for_work(&mut self) {
  48. //
  49. }
  50. }