MCPcopy Create free account
hub / github.com/base/base / insert

Method insert

crates/utilities/runtime/src/deterministic/executor.rs:116–125  ·  view source on GitHub ↗

Insert a new task into the running map and push it onto the ready queue.

(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>)

Source from the content-addressed store, hash-verified

114impl Tasks {
115 /// Insert a new task into the running map and push it onto the ready queue.
116 pub fn insert(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>) {
117 let id = {
118 let mut c = self.counter.lock().unwrap();
119 let id = *c;
120 *c += 1;
121 id
122 };
123 self.running.lock().unwrap().insert(id, Arc::new(Task { future: Mutex::new(future) }));
124 self.queue(id);
125 }
126
127 /// Push a task ID onto the ready queue (called by `TaskWaker`).
128 pub fn queue(&self, id: u128) {

Calls 3

queueMethod · 0.80
newFunction · 0.50
lockMethod · 0.45