MCPcopy Index your code
hub / github.com/ccxt/ccxt / spawnWithResult

Method spawnWithResult

java/lib/src/main/java/io/github/ccxt/Exchange.java:1861–1876  ·  view source on GitHub ↗

Start an async method-name call on the virtual executor and return a Future that resolves with the result (or is rejected on failure). Used by WS transpile output to replace TS `this.spawn(this.method, ...args)` when the return value is captured (e.g., stored in a cache). Mirrors how the TS Promise

(String methodName, Object... args)

Source from the content-addressed store, hash-verified

1859 * how the TS Promise returned by `this.spawn(...)` is consumed.
1860 */
1861 public io.github.ccxt.ws.Future spawnWithResult(String methodName, Object... args) {
1862 io.github.ccxt.ws.Future fut = new io.github.ccxt.ws.Future();
1863 this.spawn(() -> {
1864 try {
1865 Object result = Helpers.callDynamically(this, methodName, args);
1866 // callDynamically may return a CompletableFuture — unwrap
1867 if (result instanceof java.util.concurrent.CompletableFuture<?> cf) {
1868 result = cf.join();
1869 }
1870 fut.resolve(result);
1871 } catch (Exception e) {
1872 fut.reject(e);
1873 }
1874 });
1875 return fut;
1876 }
1877
1878 /**
1879 * Load order book snapshot from REST and merge with cached deltas.

Callers 1

negotiateMethod · 0.80

Calls 4

spawnMethod · 0.95
callDynamicallyMethod · 0.95
resolveMethod · 0.95
rejectMethod · 0.95

Tested by

no test coverage detected