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

37
LINES

< > BotCompany Repo | #1026811 // FunctionsLoader

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (10346L/72K).

sclass FunctionsLoader implements AutoCloseable {
  Set<S> functions;
  O blob;
  Throwable exception;
  bool loading;
  L<Runnable> onLoaded = syncList(); // also called on fail
  O[] loadFunctionsParams;
  
  *(Iterable<S> functions) { this.functions = asSet(functions); }

  synchronized void loadInBackground {
    if (!loading) {
      loading = true;
      startThread(r load);
    }
  }
  
  void load {
    try {
      blob = loadFunctions(functions, loadFunctionsParams);
    } catch print e {
      exception = e;
    }
    pcallFAll(onLoaded);
  }
  
  public void close {
    dispose blob;
  }
  
  bool loaded() { ret blob != null || exception != null; }
  bool hasCode() { ret blob != null; }
  
  O blob() { ret blob; }
  
  void onLoaded(Runnable r) { onLoaded.add(r); }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026811
Snippet name: FunctionsLoader
Eternal ID of this version: #1026811/9
Text MD5: 7f38720ef5e145948fcfa34db38da080
Transpilation MD5: dbce0999e4a114dc6d039de8604f4752
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-23 23:02:01
Source code size: 824 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 254 / 641
Version history: 8 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)