public class FiberLocal<T> extends Object
Example usage:
static final FiberLocal<User> fiberLocalUser = new FiberLocal<>(); Async<Void> action1() { fiberLocalUser.set(user); return Fiber.sleep(Duration.ofSeconds(1)) .then( v->action2() ); } Async<Void> action2() { User user = fiberLocalUser.get(); ... }
The initial fiber-local value of a FiberLocal is always null.
Constructor and Description |
---|
FiberLocal()
Create a FiberLocal variable.
|
public FiberLocal()
public T get() throws IllegalStateException
The initial fiber-local value, before any set()
calls, is null.
IllegalStateException
- if `Fiber.current()==null`public void set(T value) throws IllegalStateException
IllegalStateException
- if `Fiber.current()==null`