This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Running 3 test cases... | |
WARNING: debug mode. Not for benchmarking or production | |
EAL: Detected lcore 0 as core 0 on socket 0 | |
EAL: Detected lcore 1 as core 1 on socket 0 | |
EAL: Detected lcore 2 as core 2 on socket 0 | |
EAL: Detected lcore 3 as core 3 on socket 0 | |
EAL: Detected lcore 4 as core 4 on socket 0 | |
EAL: Detected lcore 5 as core 8 on socket 0 | |
EAL: Detected lcore 6 as core 9 on socket 0 | |
EAL: Detected lcore 7 as core 10 on socket 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub async fn read_at<'_>(&'_ self, pos: u64, size: usize) -> Result<ReadResult> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub async fn get_buffer_aligned<'_>( | |
&'_ mut self, | |
len: u64 | |
) -> Result<ReadResult> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn spawn<F, T>(f: F) -> JoinHandle<T> | |
where | |
F: FnOnce() -> T, | |
F: Send + 'static, | |
T: Send + 'static, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let keep_running = Rc::new(Cell::new(true)); | |
let kr = keep_running.clone(); // there are now two objects pointing to the same place | |
// the ownership of this copy is passed to the task. | |
let background_printer = Task::local(async move { | |
while kr.get() { | |
sleep(Duration::from_millis(100)).await; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{rc::Rc, time::Instant}; | |
struct Foo { | |
val: usize, | |
} | |
impl Foo { | |
fn new(val: usize) -> Self { | |
Foo { val } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async fn some_async_function() { | |
let shared = Rc::new(Cell::new(0)); | |
let s = shared.clone(); | |
let x = Task::local(async move { | |
do_async_work(s).await; // used a Clone of shared state | |
}); // <== task starts executing here | |
do_more_work(shared); // <== may be still background executing here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn scoped_task_unsound() { | |
let le = LocalExecutor::default(); | |
le.run(async { | |
{ | |
let msg = &mut "hello"; | |
let scoped = ScopedTask::local(async { | |
eprintln!("write to invalid address"); | |
*msg = "oh no"; | |
}); | |
std::mem::forget(scoped); // drop() doesn't run, so the task survives. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm" | |
@Entity() | |
export class Photo { | |
@PrimaryGeneratedColumn() | |
id: number | |
@Column({ | |
length: 100, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const usersWithPosts = await prisma.user.findMany({ | |
orderBy: [ | |
{ | |
role: 'desc', | |
}, | |
{ | |
name: 'desc', | |
}, | |
], | |
include: { |
OlderNewer