Procházet zdrojové kódy

Merge pull request #91 from michaelmelanson/amlcontext-send-sync

Regression: Ensure `AmlContext` is `Send` and `Sync` again.
Isaac Woods před 3 roky
rodič
revize
52ae6a36b7
2 změnil soubory, kde provedl 5 přidání a 5 odebrání
  1. 1 1
      aml/src/lib.rs
  2. 4 4
      aml/src/value.rs

+ 1 - 1
aml/src/lib.rs

@@ -673,7 +673,7 @@ impl AmlContext {
 }
 
 // TODO: docs
-pub trait Handler {
+pub trait Handler: Send + Sync {
     fn read_u8(&self, address: usize) -> u8;
     fn read_u16(&self, address: usize) -> u16;
     fn read_u32(&self, address: usize) -> u32;

+ 4 - 4
aml/src/value.rs

@@ -1,5 +1,5 @@
 use crate::{misc::ArgNum, AmlContext, AmlError, AmlHandle, AmlName};
-use alloc::{rc::Rc, string::String, vec::Vec};
+use alloc::{string::String, sync::Arc, vec::Vec};
 use bit_field::BitField;
 use core::{cmp, fmt, fmt::Debug};
 
@@ -154,7 +154,7 @@ pub enum AmlType {
 #[derive(Clone)]
 pub enum MethodCode {
     Aml(Vec<u8>),
-    Native(Rc<dyn Fn(&mut AmlContext) -> Result<AmlValue, AmlError>>),
+    Native(Arc<dyn Fn(&mut AmlContext) -> Result<AmlValue, AmlError> + Send + Sync>),
 }
 
 impl fmt::Debug for MethodCode {
@@ -218,10 +218,10 @@ impl AmlValue {
 
     pub fn native_method<F>(arg_count: u8, serialize: bool, sync_level: u8, f: F) -> AmlValue
     where
-        F: Fn(&mut AmlContext) -> Result<AmlValue, AmlError> + 'static,
+        F: (Fn(&mut AmlContext) -> Result<AmlValue, AmlError>) + 'static + Send + Sync,
     {
         let flags = MethodFlags::new(arg_count, serialize, sync_level);
-        AmlValue::Method { flags, code: MethodCode::Native(Rc::new(f)) }
+        AmlValue::Method { flags, code: MethodCode::Native(Arc::new(f)) }
     }
 
     pub fn type_of(&self) -> AmlType {