Binds this variable to the given value. Can only be called once; subsequent calls throw IllegalStateException. @param value the value to bind (may be null) @throws IllegalStateException if already bound
(T value)
| 77 | * @throws IllegalStateException if already bound |
| 78 | */ |
| 79 | public void bind(T value) { |
| 80 | if (!future.complete(value)) { |
| 81 | String current; |
| 82 | try { |
| 83 | current = String.valueOf(future.getNow(null)); |
| 84 | } catch (CompletionException e) { |
| 85 | current = "error: " + e.getCause(); |
| 86 | } |
| 87 | throw new IllegalStateException( |
| 88 | "DataflowVariable is already bound to: " + current); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Binds this variable to an error. Any thread awaiting the value |