Skip to content

Commit

Permalink
fix: 修复没有还原限制策略的方法的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow3aaa committed Dec 29, 2024
1 parent 4b2f447 commit 604a62f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/framework/extension/api/helper_funs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ use crate::cpu_common::{

static WARNING_FLAG: AtomicBool = AtomicBool::new(false);

pub fn remove_extra_policy(policy: i32) {
*EXTRA_POLICY_MAP
.get()
.context("EXTRA_POLICY_MAP not initialized")
.unwrap()
.get(&policy)
.context("CPU Policy not found")
.unwrap()
.lock() = ExtraPolicy::None;
}

pub fn set_extra_policy_abs(policy: i32, min: Option<isize>, max: Option<isize>) {
let extra_policy = if min.is_none() && max.is_none() {
ExtraPolicy::None
Expand Down
9 changes: 9 additions & 0 deletions src/framework/extension/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ fn load_extensions() -> Result<ExtensionMap> {
})?,
)?;

// Add in api v4
lua.globals().set(
"remove_extra_policy",
lua.create_function(|_, policy| {
helper_funs::remove_extra_policy(policy);
Ok(())
})?,
)?;

match lua.load(&file).exec() {
Ok(()) => {
info!("Extension loaded successfully: {path:?}");
Expand Down

0 comments on commit 604a62f

Please sign in to comment.