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).

1  
// Note: The maps are nested like with ThreadLocal (lookup thread first, then variable.)
2  
sclass FiberLocal<A> implements IVar<A> {
3  
  // internal
4  
  Map<IVar, O> flv() { ret currentFiber().fiberLocalValues; }
5  
  
6  
  bool isSet() { ret flv().containsKey(this); }
7  
  
8  
  public A get() {
9  
    ret (A) flv().get(this);
10  
  }
11  
  
12  
  public void set(A a) {
13  
    mapPutOrRemove(flv(), this, a);
14  
  }
15  
}

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: 89 / 187
Version history: 4 change(s)
Referenced in: [show references]