Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1011310 // DependentCache

JavaX fragment (include)

// f is a function or an instance of Cache (the dependee)
sclass DependentCache<A> extends Cache<A> {
  O depF, lastDep;
  
  *() {}
  *(O *maker, O *depF) {}
  
  A get() {
    if (hasLock(lock)) ret value; // Must be called from within maker
    {
      lock lock;
      O dep;
      if (depF instanceof Cache) dep = depF/Cache.changeCount;
      else {
        dep = callF(depF);
        if (dep instanceof Cache) dep = dep/Cache.changeCount;
      }
      if (neq(dep, lastDep)) {
        clear();
        lastDep = dep;
      }
    }
    ret super.get();
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011310
Snippet name: DependentCache
Eternal ID of this version: #1011310/6
Text MD5: d505bfb8dcf5b87142e3bb1b2a877729
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-22 12:04:33
Source code size: 589 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 502 / 2055
Version history: 5 change(s)
Referenced in: #1018251 - MechListDependentCache - depends on a single mech list
#1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)