Skip to content

Commit

Permalink
Added trashCache function
Browse files Browse the repository at this point in the history
- Increased `MANAGER_CACHE` from 5 to 8.
  • Loading branch information
latenitefilms committed Jul 13, 2023
1 parent e1dce36 commit 6381e8a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Source/Frameworks/gyroflow/inc/gyroflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ const char* processFrame(
void *out_mtl_texture,
void *command_queue
);

uint32_t trashCache();
20 changes: 19 additions & 1 deletion Source/Frameworks/gyroflow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,25 @@ use std::sync::Mutex; // A mutual exclusion primitive usef
// each pixel format:
//---------------------------------------------------------
lazy_static! {
static ref MANAGER_CACHE: Mutex<LruCache<String, Arc<StabilizationManager>>> = Mutex::new(LruCache::new(std::num::NonZeroUsize::new(5).unwrap()));
static ref MANAGER_CACHE: Mutex<LruCache<String, Arc<StabilizationManager>>> = Mutex::new(LruCache::new(std::num::NonZeroUsize::new(8).unwrap()));
}

//---------------------------------------------------------
// The "Trash Cache" function that gets triggered from
// Objective-C Land:
//---------------------------------------------------------
#[no_mangle]
pub extern "C" fn trashCache() -> u32 {
//---------------------------------------------------------
// Trash the Cache:
//---------------------------------------------------------
let mut cache = MANAGER_CACHE.lock().unwrap();
cache.clear();

//---------------------------------------------------------
// Return the Cache Size:
//---------------------------------------------------------
cache.len() as u32
}

//---------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions Source/Gyroflow/Plugin/GyroflowPlugIn.m
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,13 @@ - (void)buttonLoadLastGyroflowProject {
// BUTTON: 'Reload Gyroflow Project'
//---------------------------------------------------------
- (void)buttonReloadGyroflowProject {

//---------------------------------------------------------
// Trash all the caches in Rust land:
//---------------------------------------------------------
uint32_t cacheSize = trashCache();
NSLog(@"[Gyroflow Toolbox Renderer]: Rust MANAGER_CACHE size after trashing (should be zero): %u", cacheSize);

//---------------------------------------------------------
// Load the Custom Parameter Action API:
//---------------------------------------------------------
Expand Down

0 comments on commit 6381e8a

Please sign in to comment.