diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shareable_cache.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/shareable_cache.rs b/src/shareable_cache.rs index b6c6654..a8fee51 100644 --- a/src/shareable_cache.rs +++ b/src/shareable_cache.rs @@ -1,9 +1,13 @@ +use std::cell::RefCell; +use std::rc::Rc; + use rustv::isa; use rustv::memory::{MemoryInterface, Result, SharedMemory}; /// A cache that can be used as two separate caches or one /// set-associative cache. -struct ShareableCache<'a> { +#[derive(Clone)] +pub struct ShareableCache<'a> { // The idea is to create two separate ShareableCaches, one for // each player. primary: SharedMemory<'a>, @@ -14,18 +18,19 @@ struct ShareableCache<'a> { impl<'a> ShareableCache<'a> { pub fn new(cache1: SharedMemory<'a>, cache2: SharedMemory<'a>) - -> (ShareableCache<'a>, ShareableCache<'a>) { - (ShareableCache { + -> (Rc<RefCell<ShareableCache<'a>>>, + Rc<RefCell<ShareableCache<'a>>>) { + (Rc::new(RefCell::new(ShareableCache { primary: cache1.clone(), secondary: cache2.clone(), secondary_enabled: false, use_secondary: false, - }, ShareableCache { + })), Rc::new(RefCell::new(ShareableCache { primary: cache2.clone(), secondary: cache1.clone(), secondary_enabled: false, use_secondary: false, - }) + }))) } pub fn enable_secondary(&mut self) { |