void (@NotNull Task<?, ?> task, int attempt) { try (AccessToken ignored = ClientId.withClientId(task.clientId)) { try { if (task.canInvoke(disposed)) { if (!startTask(task, attempt)) return; if (task instanceof Task.Async<?> t) { Promise<?> incomplete = t.setDone(); if (incomplete != null) { count.incrementAndGet(); incomplete .onError(th -> handleTaskError(task, th, attempt)) .onProcessed(r -> count.decrementAndGet()); } } else if (task instanceof Task.Sync<?> t) { t.setDone(); } } } catch (Throwable throwable) { handleTaskError(task, throwable, attempt); } finally { count.decrementAndGet(); } } }