├── .gitignore
├── .travis.yml
├── .travis
└── maven-settings.xml
├── README.md
├── pom.xml
└── src
├── main
└── resources
│ ├── Vavr.gwt.xml
│ └── super
│ ├── io
│ └── vavr
│ │ └── concurrent
│ │ ├── CurrentThreadExecutorService.java
│ │ ├── CurrentThreadFuture.java
│ │ └── FutureImpl.java
│ └── java
│ ├── lang
│ ├── InterruptedException.java
│ ├── LinkageError.java
│ ├── ThreadDeath.java
│ └── VirtualMachineError.java
│ └── util
│ └── concurrent
│ ├── Callable.java
│ ├── CancellationException.java
│ ├── ExecutionException.java
│ ├── Executor.java
│ ├── ExecutorService.java
│ ├── Executors.java
│ ├── ForkJoinPool.java
│ ├── Future.java
│ ├── TimeUnit.java
│ ├── TimeoutException.java
│ └── atomic
│ ├── AtomicBoolean.java
│ ├── AtomicInteger.java
│ └── AtomicReference.java
└── test
└── java
├── TestModule.gwt.xml
└── client
├── CollectionsTestGwt.java
├── ConcurrentTest1.java
├── ConcurrentTest2.java
└── GwtVavrTestSuite.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # -- Maven
2 | target
3 | *.versionsBackup
4 |
5 | # -- Eclipse
6 | .classpath
7 | .project
8 | .settings
9 | bin
10 |
11 | # -- IntelliJ IDEA
12 | .idea
13 | *.iml
14 |
15 | # -- Mac OS
16 | .DS_Store
17 |
18 | # -- Java
19 | hs_err_pid*
20 |
21 | # -- Emacs
22 | .#*
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - oraclejdk8
4 | env:
5 | global:
6 | - secure: FjwU54kfDaAzg1qZilqMhRjr7YJXdj/ZJAHJ8qvmznziV3r5TLPuxe6gJa8qkCpoSTYqtB1gh0irE5RGDtdYrj9aW4OhaFVKHjtlM1bYHRU+pfNcZ3BmcTC9A94H+cGOBo9YNKNBbc16AGz6Juthug7FUE8vrBDB1Qp03KJLannQN57D/hVKY569IzmCvv7eAz1wRxdGaehUYAKdxnQAeXKvOykATNxTGl2gPoZHfjjxZCT9yJMIAfyTAU4i9+h07dwot8B8Ve/rvEaBShZYU3gUjjkHdkBrSAptzEkpRoPIOodeob7ebMzFBgL6ghO5FJwytRsS2bhmYz/IEoq6IWmtvxK7dosLtujOEczcoWZ2cMGsg0zwe5tg9nDgV3Pb+UgURE/W75do2W9gBldt8vX6bskuTWcJFmmbBXl+eP5c3AyMmV/VNbmhTzWNuqi9MfMdKfMHKxev2RkVEe4gE04XZlQsYJQ2ee2ivnyiZwxtd8I5/9/XSlRul2925yOY9UJDbGHChSbV08P+3kBuiH6d9NtMQfzv2S+pflyXpMA/3y2GknV9dEYihGQ+qGKj4LIDzAbec8lIlrYsCb6kbQVISt5lafn0Z0aHLho48R8hdnFaY2yoH6NID35+MWcM8QVVtSTkFbWcmT87yjPbycvvislgoODvug+D7Ygee7c=
7 | - secure: I8GevzVNeNHz4XsdBmLehZ6RdGX5/aGF0kM/sB3ensCUb++1qz43KJkcWk0jEBsKKktN6tGn5L9pv8RU3w+Vb2TpqrXl+uqcm58ngXTaGBiXrZHj3MSJoFMlko6K8+soJfeucUcGV6i5pNsoJE0UH/WbiPdu9J47F4aWywT8vfJsL75FBYXHuPZXW7vUOjc8a3wXiIvTgSy2AVIuIVHLm9kNWdG5CgqHGGQAhHWjrdsgW31Oii1AoUdj36wB2/mpf2YdPoPaz0SMKkah+NoHfaPM4GBts3gQkIMzpO6xuTDnxaNrA7BiuTywNtK5yZHhwFVc6QRcrTRBKWsUlFHFChW3qiCWcNT78dVD+Jxoxbbw3RtkdQwFievzhg28mhdrcShj03X1S90WIQhV/uovgyG2DWrkZUrqZ+CipFAgpJnF7c1Q0HHvrBWwdQR8c0NTp/Te2THKDWjRtKhRajEqj0XGi6vyNgQLbvFHzIMWnzO61cZGs6bDx0hOM/1aiinKWv+a8kjL3TWSa1aKs+KUm5I9QDxpVsKBtmTFbH9yWrGpUGra2mb5IfRSnavKG2kfBiBgRn5h4gR6AECG1S8Co5aD2BJdOTSOxjVEO0b2ktGInfiSrl/mTKwfF90tUI99I2w0A2wtp3+eoSWYBERGXswQz6saotaxbobQlYzlwso=
8 | before_install:
9 | - sudo apt-get update
10 | - sudo apt-get install --only-upgrade -y oracle-java8-installer
11 | - pip install --user codecov
12 | after_success:
13 | - mvn clean deploy -DskipTests --settings .travis/maven-settings.xml
14 |
--------------------------------------------------------------------------------
/.travis/maven-settings.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | sonatype-nexus-snapshots
13 | ${env.SONATYPE_USER}
14 | ${env.SONATYPE_PASS}
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://maven-badges.herokuapp.com/maven-central/io.vavr/vavr-gwt)
2 | [](https://travis-ci.org/vavr-io/vavr-gwt)
3 | [](https://gitter.im/vavr-io/vavr)
4 |
5 | # GWT support for Vavr
6 |
7 | ### Using Vavr in GWT maven projects
8 |
9 | * Add the following maven dependency to your project:
10 |
11 | ```
12 |
13 | io.vavr
14 | vavr-gwt
15 | {vavr-current-version}
16 |
17 | ```
18 |
19 | * Inherit the `Vavr` module in your GWT module's descriptor file:
20 |
21 | ```
22 |
23 |
24 |
25 |
26 |
27 | ```
28 |
29 | * Use the Vavr APIs in your code.
30 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | 3.0.4
5 |
6 |
7 | org.sonatype.oss
8 | oss-parent
9 | 9
10 |
11 | io.vavr
12 | vavr-gwt
13 | 1.0.0-SNAPSHOT
14 | jar
15 | Vavr GWT
16 | GWT support for Vavr.
17 | http://vavr.io
18 |
19 |
20 | The Apache Software License, Version 2.0
21 | http://www.apache.org/licenses/LICENSE-2.0.txt
22 | repo
23 |
24 |
25 |
26 | scm:git:git@github.com:vavr-io/vavr-gwt.git
27 | scm:git:git@github.com:vavr-io/vavr-gwt.git
28 | git@github.com:vavr-io/vavr-gwt.git
29 | HEAD
30 |
31 |
32 |
33 | ruslansennov
34 | Ruslan Sennov
35 | ruslan.sennov@gmail.com
36 |
37 |
38 |
39 | UTF-8
40 | 3.5.2
41 | 1.0.0
42 | 1.8
43 | 1.0.0-SNAPSHOT
44 | 4.12
45 | 2.8.2
46 | 3.2.0
47 | 2.5.2
48 | 3.5.1
49 | 2.8.2
50 | 1.6
51 | 0.7.8
52 | 3.0.2
53 | 2.10.4
54 | 2.5.3
55 | 2.3
56 | 3.0.1
57 |
58 |
59 |
60 | io.vavr
61 | vavr
62 | ${vavr.version}
63 |
64 |
65 | io.vavr
66 | vavr
67 | ${vavr.version}
68 | sources
69 |
70 |
71 | io.vavr
72 | vavr-match
73 | ${vavr.version}
74 | sources
75 |
76 |
77 | com.google.gwt
78 | gwt-user
79 | ${gwt.version}
80 | provided
81 |
82 |
83 | com.google.gwt
84 | gwt-dev
85 | ${gwt.version}
86 | provided
87 |
88 |
89 | junit
90 | junit
91 | ${junit.version}
92 | test
93 |
94 |
95 | org.assertj
96 | assertj-core
97 | ${assertj.core.version}
98 | test
99 |
100 |
101 |
102 |
103 |
104 | org.apache.felix
105 | maven-bundle-plugin
106 | ${maven.bundle.version}
107 |
108 |
109 | org.codehaus.mojo
110 | versions-maven-plugin
111 | ${maven.versions.version}
112 |
113 |
114 | org.apache.maven.plugins
115 | maven-install-plugin
116 | ${maven.install.version}
117 |
118 |
119 | org.codehaus.mojo
120 | gwt-maven-plugin
121 | ${gwt.version}
122 |
123 |
124 | testing
125 | test
126 |
127 | test
128 |
129 |
130 |
131 | compiling
132 | compile
133 |
134 | compile
135 |
136 |
137 |
138 |
139 | 0
140 | -Xmx1024m
141 | true
142 |
143 |
144 |
145 |
146 |
147 |
148 | org.apache.maven.plugins
149 | maven-source-plugin
150 | ${maven.source.version}
151 |
152 |
153 | attach-sources
154 | generate-resources
155 |
156 | jar-no-fork
157 | test-jar-no-fork
158 |
159 |
160 |
161 |
162 |
163 | org.apache.maven.plugins
164 | maven-release-plugin
165 | ${maven.release.version}
166 |
167 |
168 | v@{project.version}
169 |
170 | forked-path
171 | false
172 |
173 | ${arguments} -Psonatype-oss-release
174 |
175 |
176 |
177 | org.apache.maven.plugins
178 | maven-compiler-plugin
179 | ${maven.compiler.version}
180 |
181 | ${java.version}
182 | ${java.version}
183 | true
184 | true
185 |
186 | -Xlint:all
187 | -Werror
188 |
189 |
190 |
191 |
192 | org.apache.maven.plugins
193 | maven-deploy-plugin
194 | ${maven.deploy.version}
195 |
196 |
197 | org.apache.maven.plugins
198 | maven-jar-plugin
199 | ${maven.jar.version}
200 |
201 | true
202 |
203 | ${project.build.outputDirectory}/META-INF/MANIFEST.MF
204 |
205 | io.vavr.gwt
206 |
207 |
208 |
209 |
210 |
211 | org.apache.maven.plugins
212 | maven-javadoc-plugin
213 | ${maven.javadoc.version}
214 |
215 |
216 | https://docs.oracle.com/javase/8/docs/api/
217 |
218 |
219 |
220 |
221 | org.apache.felix
222 | maven-bundle-plugin
223 | ${maven.bundle.version}
224 |
225 |
226 | bundle-manifest
227 | process-classes
228 |
229 | manifest
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 | ci
241 |
242 |
243 | env.CI
244 |
245 |
246 |
247 |
248 |
249 | org.jacoco
250 | jacoco-maven-plugin
251 | ${maven.jacoco.version}
252 |
253 |
254 |
255 | prepare-agent
256 |
257 |
258 |
259 | report
260 | test
261 |
262 | report
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 | release-sign-artifacts
273 |
274 |
275 |
276 | performRelease
277 | true
278 |
279 |
280 |
281 |
282 |
283 | org.apache.maven.plugins
284 | maven-gpg-plugin
285 | ${maven.gpg.version}
286 |
287 |
288 | sign-artifacts
289 | verify
290 |
291 | sign
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 | eclipse-m2e
302 |
303 |
304 | m2e.version
305 |
306 |
307 |
308 |
309 |
310 |
311 | org.eclipse.m2e
312 | lifecycle-mapping
313 | ${eclipse.lifecycle.mapping.version}
314 |
315 |
316 |
317 |
319 |
320 |
321 | org.apache.maven.plugins
322 | maven-enforcer-plugin
323 | [0,)
324 |
325 | enforce
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 | org.apache.felix
335 | maven-bundle-plugin
336 | [0,)
337 |
338 | manifest
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 | org.codehaus.mojo
348 | gwt-maven-plugin
349 | [2.8.0,)
350 |
351 | compile
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
--------------------------------------------------------------------------------
/src/main/resources/Vavr.gwt.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/super/io/vavr/concurrent/CurrentThreadExecutorService.java:
--------------------------------------------------------------------------------
1 | /* __ __ __ __ __ ___
2 | * \ \ / / \ \ / / __/
3 | * \ \/ / /\ \ \/ / /
4 | * \____/__/ \__\____/__/
5 | *
6 | * Copyright 2014-2017 Vavr, http://vavr.io
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 | package io.vavr.concurrent;
21 |
22 | import java.util.concurrent.ExecutorService;
23 | import java.util.concurrent.Future;
24 |
25 | /**
26 | * GWT emulated implementation of {@link ExecutorService} which executes all tasks in the current thread.
27 | */
28 | public class CurrentThreadExecutorService implements ExecutorService {
29 |
30 | @Override public Future> submit(Runnable task) {
31 | task.run();
32 |
33 | return new CurrentThreadFuture<>(null, null);
34 | }
35 |
36 | @Override public void execute(Runnable command) {
37 | command.run();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/resources/super/io/vavr/concurrent/CurrentThreadFuture.java:
--------------------------------------------------------------------------------
1 | /* __ __ __ __ __ ___
2 | * \ \ / / \ \ / / __/
3 | * \ \/ / /\ \ \/ / /
4 | * \____/__/ \__\____/__/
5 | *
6 | * Copyright 2014-2017 Vavr, http://vavr.io
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 | package io.vavr.concurrent;
21 |
22 | import java.util.concurrent.ExecutionException;
23 | import java.util.concurrent.TimeUnit;
24 | import java.util.concurrent.TimeoutException;
25 |
26 | /**
27 | * GWT emulated implementation of {@link java.util.concurrent.Future}.
28 | */
29 | class CurrentThreadFuture implements java.util.concurrent.Future {
30 |
31 | private T result;
32 |
33 | private Exception exception;
34 |
35 | public CurrentThreadFuture(T result, Exception exception) {
36 | this.result = result;
37 | this.exception = exception;
38 | }
39 |
40 | @Override public boolean cancel(boolean mayInterruptIfRunning) { return false; }
41 |
42 | @Override public boolean isCancelled() { return false; }
43 |
44 | @Override public boolean isDone() {
45 | return true;
46 | }
47 |
48 | @Override public T get() throws InterruptedException, ExecutionException {
49 | if (exception != null) {
50 | throw new ExecutionException(exception);
51 | }
52 |
53 | return result;
54 | }
55 |
56 | @Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException,
57 | TimeoutException {
58 | return get();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/resources/super/io/vavr/concurrent/FutureImpl.java:
--------------------------------------------------------------------------------
1 | /* __ __ __ __ __ ___
2 | * \ \ / / \ \ / / __/
3 | * \ \/ / /\ \ \/ / /
4 | * \____/__/ \__\____/__/
5 | *
6 | * Copyright 2014-2017 Vavr, http://vavr.io
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 | package io.vavr.concurrent;
21 |
22 | import io.vavr.CheckedConsumer;
23 | import io.vavr.CheckedFunction1;
24 | import io.vavr.collection.Queue;
25 | import io.vavr.control.Option;
26 | import io.vavr.control.Try;
27 |
28 | import java.util.Objects;
29 | import java.util.concurrent.*;
30 | import java.util.function.Consumer;
31 | import java.util.function.Predicate;
32 |
33 | /**
34 | * GWT emulated version of {@link FutureImpl} with removed uses of Object's wait and notify methods.
35 | */
36 | final class FutureImpl implements Future {
37 |
38 | /**
39 | * Used to start new threads.
40 | */
41 | private final Executor executor;
42 |
43 | /**
44 | * Used to synchronize state changes.
45 | */
46 | private final Object lock = new Object();
47 |
48 | /**
49 | * Indicates if this Future is cancelled
50 | */
51 | @GuardedBy("lock")
52 | private volatile boolean cancelled;
53 |
54 | /**
55 | * Once the Future is completed, the value is defined.
56 | */
57 | @GuardedBy("lock")
58 | private volatile Option> value;
59 |
60 | /**
61 | * The queue of actions is filled when calling onComplete() before the Future is completed or cancelled.
62 | * Otherwise actions = null.
63 | */
64 | @GuardedBy("lock")
65 | private Queue>> actions;
66 |
67 | // single constructor
68 | private FutureImpl(Executor executor, Option> value, Queue>> actions, Computation computation) {
69 | this.executor = executor;
70 | synchronized (lock) {
71 | this.cancelled = false;
72 | this.value = value;
73 | this.actions = actions;
74 | try {
75 | computation.execute(this::tryComplete, this::updateThread);
76 | } catch(Throwable x) {
77 | tryComplete(Try.failure(x));
78 | }
79 | }
80 | }
81 |
82 | /**
83 | * Creates a {@code FutureImpl} that is immediately completed with the given value. No task will be started.
84 | *
85 | * @param executor An {@link Executor} to run and control the computation and to perform the actions.
86 | * @param value the result of this Future
87 | */
88 | @SuppressWarnings("unchecked")
89 | static FutureImpl of(Executor executor, Try extends T> value) {
90 | return new FutureImpl<>(executor, Option.some(Try.narrow(value)), null, (tryComplete, updateThread) -> {});
91 | }
92 |
93 | /**
94 | * Creates a {@code FutureImpl} that is eventually completed.
95 | * The given {@code computation} is synchronously executed, no thread is started.
96 | *
97 | * @param executor An {@link Executor} to run and control the computation and to perform the actions.
98 | * @param computation A non-blocking computation
99 | * @param value type of the Future
100 | * @return a new {@code FutureImpl} instance
101 | */
102 | static FutureImpl sync(Executor executor, CheckedConsumer>> computation) {
103 | return new FutureImpl<>(executor, Option.none(), Queue.empty(), (tryComplete, updateThread) -> {
104 | computation.accept(tryComplete);
105 | });
106 | }
107 |
108 | /**
109 | * Creates a {@code FutureImpl} that is eventually completed.
110 | * The given {@code computation} is asynchronously executed, a new thread is started.
111 | *
112 | * @param executor An {@link Executor} to run and control the computation and to perform the actions.
113 | * @param computation A (possibly blocking) computation
114 | * @param value type of the Future
115 | * @return a new {@code FutureImpl} instance
116 | */
117 | static FutureImpl async(Executor executor, CheckedConsumer>> computation) {
118 | return new FutureImpl<>(executor, Option.none(), Queue.empty(), (tryComplete, updateThread) -> executor.execute(() -> {
119 | try {
120 | computation.accept(tryComplete);
121 | } catch (Throwable x) {
122 | tryComplete.test(Try.failure(x));
123 | }
124 | }));
125 | }
126 |
127 | @Override
128 | public Future await() {
129 | return this;
130 | }
131 |
132 | @Override
133 | public Future await(long timeout, TimeUnit unit) {
134 | return this;
135 | }
136 |
137 | @Override
138 | public Future cancel(boolean mayInterruptIfRunning) {
139 | if (!isCompleted()) {
140 | this.cancelled = tryComplete(Try.failure(new CancellationException()));
141 | }
142 | return this;
143 | }
144 |
145 | private void updateThread() {
146 | }
147 |
148 | @Override
149 | public Executor executor() {
150 | return executor;
151 | }
152 |
153 | @Override
154 | public Option> getValue() {
155 | return value;
156 | }
157 |
158 | @Override
159 | public boolean isCancelled() {
160 | return cancelled;
161 | }
162 |
163 | @Override
164 | public boolean isCompleted() {
165 | return value.isDefined();
166 | }
167 |
168 | @SuppressWarnings("unchecked")
169 | @Override
170 | public Future onComplete(Consumer super Try> action) {
171 | Objects.requireNonNull(action, "action is null");
172 | if (isCompleted()) {
173 | perform(action);
174 | } else {
175 | synchronized (lock) {
176 | if (isCompleted()) {
177 | perform(action);
178 | } else {
179 | actions = actions.enqueue((Consumer>) action);
180 | }
181 | }
182 | }
183 | return this;
184 | }
185 |
186 | // This class is MUTABLE and therefore CANNOT CHANGE DEFAULT equals() and hashCode() behavior.
187 | // See http://stackoverflow.com/questions/4718009/mutable-objects-and-hashcode
188 |
189 | @Override
190 | public String toString() {
191 | final Option> value = this.value;
192 | final String s = (value == null || value.isEmpty()) ? "?" : value.get().toString();
193 | return stringPrefix() + "(" + s + ")";
194 | }
195 |
196 | /**
197 | * INTERNAL METHOD, SHOULD BE USED BY THE CONSTRUCTOR, ONLY.
198 | *
199 | * Completes this Future with a value and performs all actions.
200 | *
201 | * This method is idempotent. I.e. it does nothing, if this Future is already completed.
202 | *
203 | * @param value A Success containing a result or a Failure containing an Exception.
204 | * @throws IllegalStateException if the Future is already completed or cancelled.
205 | * @throws NullPointerException if the given {@code value} is null.
206 | */
207 | private boolean tryComplete(Try extends T> value) {
208 | Objects.requireNonNull(value, "value is null");
209 | if (isCompleted()) {
210 | return false;
211 | } else {
212 | final Queue>> actions;
213 | // it is essential to make the completed state public *before* performing the actions
214 | synchronized (lock) {
215 | if (isCompleted()) {
216 | actions = null;
217 | } else {
218 | // the job isn't set to null, see isCancelled()
219 | actions = this.actions;
220 | this.value = Option.some(Try.narrow(value));
221 | this.actions = null;
222 | }
223 | }
224 | if (actions != null) {
225 | actions.forEach(this::perform);
226 | return true;
227 | } else {
228 | return false;
229 | }
230 | }
231 | }
232 |
233 | private void perform(Consumer super Try> action) {
234 | try {
235 | executor.execute(() -> action.accept(value.get()));
236 | } catch(Throwable x) {
237 | // ignored // TODO: tell UncaughtExceptionHandler?
238 | }
239 | }
240 |
241 | private interface Computation {
242 | void execute(Predicate> tryComplete, Runnable updateThread) throws Throwable;
243 | }
244 | }
245 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/lang/InterruptedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Oracle designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Oracle in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 | * or visit www.oracle.com if you need additional information or have any
23 | * questions.
24 | */
25 |
26 | package java.lang;
27 |
28 | /**
29 | * Thrown when a thread is waiting, sleeping, or otherwise occupied,
30 | * and the thread is interrupted, either before or during the activity.
31 | * Occasionally a method may wish to test whether the current
32 | * thread has been interrupted, and if so, to immediately throw
33 | * this exception. The following code can be used to achieve
34 | * this effect:
35 | *
36 | * if (Thread.interrupted()) // Clears interrupted status!
37 | * throw new InterruptedException();
38 | *
39 | *
40 | * @author Frank Yellin
41 | * @see java.lang.Object#wait()
42 | * @see java.lang.Object#wait(long)
43 | * @see java.lang.Object#wait(long, int)
44 | * @see java.lang.Thread#sleep(long)
45 | * @see java.lang.Thread#interrupt()
46 | * @see java.lang.Thread#interrupted()
47 | * @since JDK1.0
48 | */
49 | public
50 | class InterruptedException extends Exception {
51 | private static final long serialVersionUID = 6700697376100628473L;
52 |
53 | /**
54 | * Constructs an InterruptedException with no detail message.
55 | */
56 | public InterruptedException() {
57 | super();
58 | }
59 |
60 | /**
61 | * Constructs an InterruptedException with the
62 | * specified detail message.
63 | *
64 | * @param s the detail message.
65 | */
66 | public InterruptedException(String s) {
67 | super(s);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/lang/LinkageError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Oracle designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Oracle in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 | * or visit www.oracle.com if you need additional information or have any
23 | * questions.
24 | */
25 |
26 | package java.lang;
27 |
28 | /**
29 | * Subclasses of {@code LinkageError} indicate that a class has
30 | * some dependency on another class; however, the latter class has
31 | * incompatibly changed after the compilation of the former class.
32 | *
33 | *
34 | * @author Frank Yellin
35 | * @since JDK1.0
36 | */
37 | public
38 | class LinkageError extends Error {
39 | private static final long serialVersionUID = 3579600108157160122L;
40 |
41 | /**
42 | * Constructs a {@code LinkageError} with no detail message.
43 | */
44 | public LinkageError() {
45 | super();
46 | }
47 |
48 | /**
49 | * Constructs a {@code LinkageError} with the specified detail
50 | * message.
51 | *
52 | * @param s the detail message.
53 | */
54 | public LinkageError(String s) {
55 | super(s);
56 | }
57 |
58 | /**
59 | * Constructs a {@code LinkageError} with the specified detail
60 | * message and cause.
61 | *
62 | * @param s the detail message.
63 | * @param cause the cause, may be {@code null}
64 | * @since 1.7
65 | */
66 | public LinkageError(String s, Throwable cause) {
67 | super(s, cause);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/lang/ThreadDeath.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Oracle designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Oracle in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 | * or visit www.oracle.com if you need additional information or have any
23 | * questions.
24 | */
25 |
26 | package java.lang;
27 |
28 | /**
29 | * An instance of {@code ThreadDeath} is thrown in the victim thread
30 | * when the (deprecated) {@link Thread#stop()} method is invoked.
31 | *
32 | *
An application should catch instances of this class only if it
33 | * must clean up after being terminated asynchronously. If
34 | * {@code ThreadDeath} is caught by a method, it is important that it
35 | * be rethrown so that the thread actually dies.
36 | *
37 | *
The {@linkplain ThreadGroup#uncaughtException top-level error
38 | * handler} does not print out a message if {@code ThreadDeath} is
39 | * never caught.
40 | *
41 | *
The class {@code ThreadDeath} is specifically a subclass of
42 | * {@code Error} rather than {@code Exception}, even though it is a
43 | * "normal occurrence", because many applications catch all
44 | * occurrences of {@code Exception} and then discard the exception.
45 | *
46 | * @since JDK1.0
47 | */
48 |
49 | public class ThreadDeath extends Error {
50 | private static final long serialVersionUID = -4417128565033088268L;
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/lang/VirtualMachineError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Oracle designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Oracle in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 | * or visit www.oracle.com if you need additional information or have any
23 | * questions.
24 | */
25 |
26 | package java.lang;
27 |
28 | /**
29 | * Thrown to indicate that the Java Virtual Machine is broken or has
30 | * run out of resources necessary for it to continue operating.
31 | *
32 | *
33 | * @author Frank Yellin
34 | * @since JDK1.0
35 | */
36 | abstract public class VirtualMachineError extends Error {
37 | private static final long serialVersionUID = 4161983926571568670L;
38 |
39 | /**
40 | * Constructs a VirtualMachineError with no detail message.
41 | */
42 | public VirtualMachineError() {
43 | super();
44 | }
45 |
46 | /**
47 | * Constructs a VirtualMachineError with the specified
48 | * detail message.
49 | *
50 | * @param message the detail message.
51 | */
52 | public VirtualMachineError(String message) {
53 | super(message);
54 | }
55 |
56 | /**
57 | * Constructs a {@code VirtualMachineError} with the specified
58 | * detail message and cause.
Note that the detail message
59 | * associated with {@code cause} is not automatically
60 | * incorporated in this error's detail message.
61 | *
62 | * @param message the detail message (which is saved for later retrieval
63 | * by the {@link #getMessage()} method).
64 | * @param cause the cause (which is saved for later retrieval by the
65 | * {@link #getCause()} method). (A {@code null} value is
66 | * permitted, and indicates that the cause is nonexistent or
67 | * unknown.)
68 | * @since 1.8
69 | */
70 | public VirtualMachineError(String message, Throwable cause) {
71 | super(message, cause);
72 | }
73 |
74 | /**
75 | * Constructs an a {@code VirtualMachineError} with the specified
76 | * cause and a detail message of {@code (cause==null ? null :
77 | * cause.toString())} (which typically contains the class and
78 | * detail message of {@code cause}).
79 | *
80 | * @param cause the cause (which is saved for later retrieval by the
81 | * {@link #getCause()} method). (A {@code null} value is
82 | * permitted, and indicates that the cause is nonexistent or
83 | * unknown.)
84 | * @since 1.8
85 | */
86 | public VirtualMachineError(Throwable cause) {
87 | super(cause);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/util/concurrent/Callable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
3 | *
4 | *
5 | *
6 | *
7 | *
8 | *
9 | *
10 | *
11 | *
12 | *
13 | *
14 | *
15 | *
16 | *
17 | *
18 | *
19 | *
20 | *
21 | *
22 | *
23 | */
24 |
25 | /*
26 | *
27 | *
28 | *
29 | *
30 | *
31 | * Written by Doug Lea with assistance from members of JCP JSR-166
32 | * Expert Group and released to the public domain, as explained at
33 | * http://creativecommons.org/publicdomain/zero/1.0/
34 | */
35 |
36 | package java.util.concurrent;
37 |
38 | /**
39 | * A task that returns a result and may throw an exception.
40 | * Implementors define a single method with no arguments called
41 | * {@code call}.
42 | *
43 | *
The {@code Callable} interface is similar to {@link
44 | * java.lang.Runnable}, in that both are designed for classes whose
45 | * instances are potentially executed by another thread. A
46 | * {@code Runnable}, however, does not return a result and cannot
47 | * throw a checked exception.
48 | *
49 | *
The {@link Executors} class contains utility methods to
50 | * convert from other common forms to {@code Callable} classes.
51 | *
52 | * @see Executor
53 | * @since 1.5
54 | * @author Doug Lea
55 | * @param the result type of method {@code call}
56 | */
57 | @FunctionalInterface
58 | public interface Callable {
59 | /**
60 | * Computes a result, or throws an exception if unable to do so.
61 | *
62 | * @return computed result
63 | * @throws Exception if unable to compute a result
64 | */
65 | V call() throws Exception;
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/util/concurrent/CancellationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
3 | *
4 | *
5 | *
6 | *
7 | *
8 | *
9 | *
10 | *
11 | *
12 | *
13 | *
14 | *
15 | *
16 | *
17 | *
18 | *
19 | *
20 | *
21 | *
22 | *
23 | */
24 |
25 | /*
26 | *
27 | *
28 | *
29 | *
30 | *
31 | * Written by Doug Lea with assistance from members of JCP JSR-166
32 | * Expert Group and released to the public domain, as explained at
33 | * http://creativecommons.org/publicdomain/zero/1.0/
34 | */
35 |
36 | package java.util.concurrent;
37 |
38 | /**
39 | * Exception indicating that the result of a value-producing task,
40 | * such as a {@link FutureTask}, cannot be retrieved because the task
41 | * was cancelled.
42 | *
43 | * @since 1.5
44 | * @author Doug Lea
45 | */
46 | public class CancellationException extends IllegalStateException {
47 | private static final long serialVersionUID = -9202173006928992231L;
48 |
49 | /**
50 | * Constructs a {@code CancellationException} with no detail message.
51 | */
52 | public CancellationException() {}
53 |
54 | /**
55 | * Constructs a {@code CancellationException} with the specified detail
56 | * message.
57 | *
58 | * @param message the detail message
59 | */
60 | public CancellationException(String message) {
61 | super(message);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/util/concurrent/ExecutionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
3 | *
4 | *
5 | *
6 | *
7 | *
8 | *
9 | *
10 | *
11 | *
12 | *
13 | *
14 | *
15 | *
16 | *
17 | *
18 | *
19 | *
20 | *
21 | *
22 | *
23 | */
24 |
25 | /*
26 | *
27 | *
28 | *
29 | *
30 | *
31 | * Written by Doug Lea with assistance from members of JCP JSR-166
32 | * Expert Group and released to the public domain, as explained at
33 | * http://creativecommons.org/publicdomain/zero/1.0/
34 | */
35 |
36 | package java.util.concurrent;
37 |
38 | /**
39 | * Exception thrown when attempting to retrieve the result of a task
40 | * that aborted by throwing an exception. This exception can be
41 | * inspected using the {@link #getCause()} method.
42 | *
43 | * @see Future
44 | * @since 1.5
45 | * @author Doug Lea
46 | */
47 | public class ExecutionException extends Exception {
48 | private static final long serialVersionUID = 7830266012832686185L;
49 |
50 | /**
51 | * Constructs an {@code ExecutionException} with no detail message.
52 | * The cause is not initialized, and may subsequently be
53 | * initialized by a call to {@link #initCause(Throwable) initCause}.
54 | */
55 | protected ExecutionException() { }
56 |
57 | /**
58 | * Constructs an {@code ExecutionException} with the specified detail
59 | * message. The cause is not initialized, and may subsequently be
60 | * initialized by a call to {@link #initCause(Throwable) initCause}.
61 | *
62 | * @param message the detail message
63 | */
64 | protected ExecutionException(String message) {
65 | super(message);
66 | }
67 |
68 | /**
69 | * Constructs an {@code ExecutionException} with the specified detail
70 | * message and cause.
71 | *
72 | * @param message the detail message
73 | * @param cause the cause (which is saved for later retrieval by the
74 | * {@link #getCause()} method)
75 | */
76 | public ExecutionException(String message, Throwable cause) {
77 | super(message, cause);
78 | }
79 |
80 | /**
81 | * Constructs an {@code ExecutionException} with the specified cause.
82 | * The detail message is set to {@code (cause == null ? null :
83 | * cause.toString())} (which typically contains the class and
84 | * detail message of {@code cause}).
85 | *
86 | * @param cause the cause (which is saved for later retrieval by the
87 | * {@link #getCause()} method)
88 | */
89 | public ExecutionException(Throwable cause) {
90 | super(cause);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/util/concurrent/Executor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
3 | *
4 | *
5 | *
6 | *
7 | *
8 | *
9 | *
10 | *
11 | *
12 | *
13 | *
14 | *
15 | *
16 | *
17 | *
18 | *
19 | *
20 | *
21 | *
22 | *
23 | */
24 |
25 | /*
26 | *
27 | *
28 | *
29 | *
30 | *
31 | * Written by Doug Lea with assistance from members of JCP JSR-166
32 | * Expert Group and released to the public domain, as explained at
33 | * http://creativecommons.org/publicdomain/zero/1.0/
34 | */
35 |
36 | package java.util.concurrent;
37 |
38 | /**
39 | * An object that executes submitted {@link Runnable} tasks. This
40 | * interface provides a way of decoupling task submission from the
41 | * mechanics of how each task will be run, including details of thread
42 | * use, scheduling, etc. An {@code Executor} is normally used
43 | * instead of explicitly creating threads. For example, rather than
44 | * invoking {@code new Thread(new(RunnableTask())).start()} for each
45 | * of a set of tasks, you might use:
46 | *
47 | *
53 | *
54 | * However, the {@code Executor} interface does not strictly
55 | * require that execution be asynchronous. In the simplest case, an
56 | * executor can run the submitted task immediately in the caller's
57 | * thread:
58 | *
59 | *
65 | *
66 | * More typically, tasks are executed in some thread other
67 | * than the caller's thread. The executor below spawns a new thread
68 | * for each task.
69 | *
70 | *
{@code
71 | * class ThreadPerTaskExecutor implements Executor {
72 | * public void execute(Runnable r) {
73 | * new Thread(r).start();
74 | * }
75 | * }}
76 | *
77 | * Many {@code Executor} implementations impose some sort of
78 | * limitation on how and when tasks are scheduled. The executor below
79 | * serializes the submission of tasks to a second executor,
80 | * illustrating a composite executor.
81 | *
82 | *
113 | *
114 | * The {@code Executor} implementations provided in this package
115 | * implement {@link ExecutorService}, which is a more extensive
116 | * interface. The {@link ThreadPoolExecutor} class provides an
117 | * extensible thread pool implementation. The {@link Executors} class
118 | * provides convenient factory methods for these Executors.
119 | *
120 | *
Memory consistency effects: Actions in a thread prior to
121 | * submitting a {@code Runnable} object to an {@code Executor}
122 | * happen-before
123 | * its execution begins, perhaps in another thread.
124 | *
125 | * @since 1.5
126 | * @author Doug Lea
127 | */
128 | public interface Executor {
129 |
130 | /**
131 | * Executes the given command at some time in the future. The command
132 | * may execute in a new thread, in a pooled thread, or in the calling
133 | * thread, at the discretion of the {@code Executor} implementation.
134 | *
135 | * @param command the runnable task
136 | * @throws RejectedExecutionException if this task cannot be
137 | * accepted for execution
138 | * @throws NullPointerException if command is null
139 | */
140 | void execute(Runnable command);
141 | }
142 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/util/concurrent/ExecutorService.java:
--------------------------------------------------------------------------------
1 | /* __ __ __ __ __ ___
2 | * \ \ / / \ \ / / __/
3 | * \ \/ / /\ \ \/ / /
4 | * \____/__/ \__\____/__/
5 | *
6 | * Copyright 2014-2017 Vavr, http://vavr.io
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 | package java.util.concurrent;
21 |
22 | /**
23 | * GWT emulated version of the {@link ExecutorService} with a limited set of methods used by Vavr.
24 | */
25 | public interface ExecutorService extends Executor {
26 |
27 | Future> submit(Runnable task);
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/resources/super/java/util/concurrent/Executors.java:
--------------------------------------------------------------------------------
1 | /* __ __ __ __ __ ___
2 | * \ \ / / \ \ / / __/
3 | * \ \/ / /\ \ \/ / /
4 | * \____/__/ \__\____/__/
5 | *
6 | * Copyright 2014-2017 Vavr, http://vavr.io
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 | package java.util.concurrent;
21 |
22 | import io.vavr.concurrent.CurrentThreadExecutorService;
23 |
24 | /**
25 | * GWT emulated implementation of {@link Executors} merged with Guava implementation to address potential
26 | * dependency conflicts.
27 | */
28 | public class Executors {
29 |
30 | public static Callable callable(Runnable task, T result) {
31 | if (task == null) {
32 | throw new NullPointerException();
33 | }
34 | return new RunnableAdapter(task, result);
35 | }
36 |
37 | public static Callable