All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dellroad.stuff.vaadin24.util.AsyncTask Maven / Gradle / Ivy

The newest version!

/*
 * Copyright (C) 2022 Archie L. Cobbs. All rights reserved.
 */

package org.dellroad.stuff.vaadin24.util;

import com.vaadin.flow.server.VaadinSession;

/**
 * Performs some task executing asynchronously and managed by an {@link AsyncTaskManager}.
 *
 * @param  task result type
 */
@FunctionalInterface
public interface AsyncTask {

    /**
     * Perform the task.
     *
     * 

* This method runs in a background thread; in particular, no {@link VaadinSession} will be locked. * *

* This method should be prepared to handle an {@linkplain Thread#interrupt interrupt} if/when * {@link AsyncTaskManager#cancelTask cancelTask()} is invoked; in that case this method may throw * {@link InterruptedException}. * *

* This task may also cancel itself by throwing an unprompted {@link InterruptedException}. * *

* It is valid for this method to return null; no special meaning is attached to null return values. * * @param id the unique ID for this task run * @return task result * @throws InterruptedException if the current thread is interrupted * @throws Exception if an error occurs during task execution */ R perform(long id) throws Exception; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy