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

15
LINES

< > BotCompany Repo | #1032580 // FiberLocal - variable local to fiber

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

Libraryless. Click here for Pure Java version (4494L/26K).

// Note: The maps are nested like with ThreadLocal (lookup thread first, then variable.)
sclass FiberLocal<A> implements IVar<A> {
  // internal
  Map<IVar, O> flv() { ret currentFiber().fiberLocalValues; }
  
  bool isSet() { ret flv().containsKey(this); }
  
  public A get() {
    ret (A) flv().get(this);
  }
  
  public void set(A a) {
    mapPutOrRemove(flv(), this, a);
  }
}

Author comment

Began life as a copy of #1011383

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032580
Snippet name: FiberLocal - variable local to fiber
Eternal ID of this version: #1032580/5
Text MD5: e330874352896d61939510abea3bbf56
Transpilation MD5: f8179c05556dee1a3009be2f95961cc9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-23 05:20:11
Source code size: 396 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 146 / 261
Version history: 4 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)