小编xma*_*s79的帖子

使用CompletableFuture重试逻辑

我需要在我正在处理的异步框架中提交任务,但我需要捕获异常,并在"中止"之前多次重试相同的任务.

我正在使用的代码是:

int retries = 0;
public CompletableFuture<Result> executeActionAsync() {

    // Execute the action async and get the future
    CompletableFuture<Result> f = executeMycustomActionHere();

    // If the future completes with exception:
    f.exceptionally(ex -> {
        retries++; // Increment the retry count
        if (retries < MAX_RETRIES)
            return executeActionAsync();  // <--- Submit one more time

        // Abort with a null value
        return null;
    });

    // Return the future    
    return f;
}
Run Code Online (Sandbox Code Playgroud)

这当前不能编译,因为lambda的返回类型是错误的:它期望a Result,但executeActionAsync返回a CompletableFuture<Result>.

如何实现这个完全异步重试逻辑?

java concurrency asynchronous exception java-8

17
推荐指数
5
解决办法
1万
查看次数

一个更好的8x8字节矩阵转置与SSE?

我发现这个职位,说明如何进行转一个8x8矩阵的字节24点的操作,和几个卷轴后有代码实现转置.但是,这种方法没有利用我们可以阻止 8x8转置为4个4x4转置的事实,并且每个转换只能在一个shuffle指令中完成(这篇文章是参考文献).所以我推出了这个解决方案:

__m128i transpose4x4mask = _mm_set_epi8(15, 11, 7, 3, 14, 10, 6, 2, 13,  9, 5, 1, 12,  8, 4, 0);
__m128i shuffle8x8Mask = _mm_setr_epi8(0, 1, 2, 3, 8, 9, 10, 11, 4,  5, 6, 7, 12,  13, 14, 15);

void TransposeBlock8x8(uint8_t *src, uint8_t *dst, int srcStride, int dstStride) {
    __m128i load0 = _mm_set_epi64x(*(uint64_t*)(src + 1 * srcStride), *(uint64_t*)(src + 0 * srcStride));
    __m128i load1 = _mm_set_epi64x(*(uint64_t*)(src + 3 * srcStride), *(uint64_t*)(src + …
Run Code Online (Sandbox Code Playgroud)

c optimization sse simd matrix

11
推荐指数
1
解决办法
1273
查看次数

CompletableFuture 从内部注入

是否可以从内部在链中注入a ?CompletableFutureCompletableFuture

我正在使用这样的函数:

public CompletableFuture<Boolean> getFutureOfMyLongRunningTask() {
    CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
        // ... Some processing here ...
        if (somecondition failed)
            return false; // Task failed!

        return true; // OK
    }).thenApplyAsync((Boolean result) -> {
        if (!result) // check of previous stage fail
            return false;

        // ... Some processing here ...

        if (!some condition satisfied) {
            // This is where I want the injection to happen. 
            // This stage should be suspended and a …
Run Code Online (Sandbox Code Playgroud)

java concurrency asynchronous future java-8

3
推荐指数
1
解决办法
1212
查看次数

将int而不是double传递给planner

是否可以使用int向量而不是使用double向量进行fft计算?

c fftw

0
推荐指数
1
解决办法
71
查看次数

标签 统计

asynchronous ×2

c ×2

concurrency ×2

java ×2

java-8 ×2

exception ×1

fftw ×1

future ×1

matrix ×1

optimization ×1

simd ×1

sse ×1