Skip to content

Instantly share code, notes, and snippets.

View glommer's full-sized avatar

Glauber Costa glommer

View GitHub Profile
@glommer
glommer / output_stream.txt
Created March 16, 2016 20:06
output stream failure output
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
pub async fn read_at<'_>(&'_ self, pos: u64, size: usize) -> Result<ReadResult>
pub async fn get_buffer_aligned<'_>(
&'_ mut self,
len: u64
) -> Result<ReadResult>
pub fn spawn<F, T>(f: F) -> JoinHandle<T>
where
F: FnOnce() -> T,
F: Send + 'static,
T: Send + 'static,
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;
}
});
use std::{rc::Rc, time::Instant};
struct Foo {
val: usize,
}
impl Foo {
fn new(val: usize) -> Self {
Foo { val }
}
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
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.
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm"
@Entity()
export class Photo {
@PrimaryGeneratedColumn()
id: number
@Column({
length: 100,
})
import { ChiselEntity } from "@chiselstrike/api"
export class Person extends ChiselEntity {
name: string;
age: number;
}