Skip to content

Commit

Permalink
KakaduContext should be Sync + Send
Browse files Browse the repository at this point in the history
  • Loading branch information
garyttierney committed Oct 26, 2024
1 parent 828542c commit 214c0f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
8 changes: 3 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::PathBuf;

use glob::glob;
use rustflags::Flag;
use std::path::PathBuf;

pub enum Arch {
X64,
Expand Down Expand Up @@ -111,10 +112,7 @@ fn main() {

for flag in rustflags::from_env() {
match flag {
Flag::Codegen {
opt,
value: Some(cpu),
} if opt == "target-cpu" => {
Flag::Codegen { opt, value: Some(cpu) } if opt == "target-cpu" => {
if cpu == "native" {
build.flag("-march=native");
} else {
Expand Down
15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
clippy::panic,
clippy::unwrap_used
)]
use ffi::LogLevel;
use std::pin::Pin;

use ffi::LogLevel;
use tokio::io::{AsyncRead, AsyncReadExt};
use tokio::runtime::Builder;
use tracing::{debug, error, info, info_span, trace, warn, Instrument};
Expand Down Expand Up @@ -74,6 +75,9 @@ mod ffi {

pub use ffi::{Info, Region};

unsafe impl Sync for ffi::KakaduContext {}
unsafe impl Send for ffi::KakaduContext {}

pub fn log(level: LogLevel, message: &str) {
match level {
LogLevel::Debug => debug!(target: "kakadu", message),
Expand All @@ -91,9 +95,7 @@ pub struct KakaduContext {

impl Default for KakaduContext {
fn default() -> Self {
Self {
inner: ffi::create_kakadu_context(),
}
Self { inner: ffi::create_kakadu_context() }
}
}

Expand Down Expand Up @@ -153,10 +155,7 @@ pub struct AsyncReader {

impl AsyncReader {
pub fn new<R: AsyncRead + 'static>(source: R, span: tracing::Span) -> Self {
Self {
stream: Box::pin(source),
span,
}
Self { stream: Box::pin(source), span }
}
}

Expand Down

0 comments on commit 214c0f8

Please sign in to comment.