// TODO: explore a more relaxed locking strategy.
private <U> CompletableFuture<U> supplyInContext(Supplier<U> supplier, String opDescription) {
        return CompletableFuture.supplyAsync(() -> {
            // TODO: explore a more relaxed locking strategy.
            writeLock.lock();
            try {
                return supplier.get();
            } catch (Throwable ex) {
                log.error("Exception in P4Runtime client of {}, executing {}", deviceId, opDescription, ex);
                throw ex;
            } finally {
                writeLock.unlock();
            }
        }, contextExecutor);
    }
private <U> CompletableFuture<U> supplyInContext(Supplier<U> supplier, String opDescription) {
return CompletableFuture.supplyAsync(() -> {
// TODO: explore a more relaxed locking strategy.
writeLock.lock();
try {
private <U> CompletableFuture<U> supplyInContext(Supplier<U> supplier, String opDescription) {
return CompletableFuture.supplyAsync(() -> {
// TODO: explore a more relaxed locking strategy.
writeLock.lock();
try {
return supplier.get();
} catch (Throwable ex) {
log.error("Exception in P4Runtime client of {}, executing {}", deviceId, opDescription, ex);
throw ex;
} finally {
writeLock.unlock();
}
}, contextExecutor);
private <U> CompletableFuture<U> supplyInContext(Supplier<U> supplier, String opDescription) {
return CompletableFuture.supplyAsync(() -> {
// TODO: explore a more relaxed locking strategy.
writeLock.lock();
try {
return supplier.get();
} catch (Throwable ex) {
log.error("Exception in P4Runtime client of {}, executing {}", deviceId, opDescription, ex);
throw ex;
} finally {
writeLock.unlock();
}
}, contextExecutor);
}