Skip to content

Commit 80cf30f

Browse files
Add async usage example
1 parent be2a371 commit 80cf30f

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

oneapi-rs/examples/async.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// Copyright (C) 2026 Intel Corporation
3+
//
4+
// Under the MIT License or the Apache License v2.0.
5+
// See LICENSE-MIT and LICENSE-APACHE for license information.
6+
// SPDX-License-Identifier: MIT OR Apache-2.0
7+
//
8+
9+
use oneapi_rs::queue::Queue;
10+
11+
#[tokio::main]
12+
async fn main() {
13+
let mut queue = Queue::new();
14+
let mut buffer = queue.alloc_shared::<u32>(10).await;
15+
16+
for e in buffer.iter() {
17+
print!("{e} ")
18+
}
19+
20+
println!();
21+
22+
for i in 0..buffer.len() {
23+
buffer[i] = i as u32;
24+
}
25+
26+
for e in buffer.iter() {
27+
print!("{e} ")
28+
}
29+
30+
println!();
31+
}

0 commit comments

Comments
 (0)