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

com.hivemq.extension.sdk.api.services.ManagedExtensionExecutorService Maven / Gradle / Ivy

There is a newer version: 4.35.0
Show newest version
/*
 * Copyright 2018-present HiveMQ GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hivemq.extension.sdk.api.services;

import com.hivemq.extension.sdk.api.annotations.DoNotImplement;
import com.hivemq.extension.sdk.api.annotations.NotNull;

import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * A shared thread pool executor which is a {@link ScheduledExecutorService}. It is recommended to use this instead of
 * creating your own thread(-pool) in your extension.
 * 

* Use this class for all concurrent code. * * @author Christoph Schäbel * @author Florian Limpöck * @since 4.0.0, CE 2019.1 */ @DoNotImplement public interface ManagedExtensionExecutorService extends ScheduledExecutorService { /** * DO NOT CALL THIS METHOD! *

* The Extension Executor Service is automatically shut down when HiveMQ is shut down. *

* Manual calls to this method from the extension system are not supported. * * @throws UnsupportedOperationException If it should be called. * @since 4.0.0, CE 2019.1 */ @Deprecated @Override default void shutdown() { throw new UnsupportedOperationException("ManagedExtensionExecutorService must not be shut down manually"); } /** * DO NOT CALL THIS METHOD! *

* The Extension Executor Service is automatically shut down when HiveMQ shuts down. *

* Manual calls to this method from the extension system are not supported. * * @throws UnsupportedOperationException If it should be called. * @since 4.0.0, CE 2019.1 */ @Deprecated @Override default @NotNull List<@NotNull Runnable> shutdownNow() { throw new UnsupportedOperationException("ManagedExtensionExecutorService must not be shut down manually"); } /** * @return A {@link CompletableFuture} representing pending completion of the task. * @see ScheduledExecutorService#submit(Runnable) * @since 4.0.0, CE 2019.1 */ @Override @NotNull CompletableFuture submit(@NotNull Runnable task); /** * @return A {@link CompletableFuture} representing pending completion of the task. * @see ScheduledExecutorService#submit(Callable) * @since 4.0.0, CE 2019.1 */ @Override @NotNull CompletableFuture submit(@NotNull Callable task); /** * @return A {@link CompletableFuture} representing pending completion of the task. * @see ScheduledExecutorService#submit(Runnable, Object) * @since 4.0.0, CE 2019.1 */ @Override @NotNull CompletableFuture submit(@NotNull Runnable task, @NotNull T result); /** * @return A {@link CompletableScheduledFuture} representing pending completion of the task. * @see ScheduledExecutorService#schedule(Runnable, long, TimeUnit) * @since 4.0.0, CE 2019.1 */ @Override @NotNull CompletableScheduledFuture schedule( @NotNull Runnable command, long delay, @NotNull TimeUnit unit); /** * @return A {@link CompletableScheduledFuture} representing pending completion of the task. * @see ScheduledExecutorService#schedule(Callable, long, TimeUnit) * @since 4.0.0, CE 2019.1 */ @Override @NotNull CompletableScheduledFuture schedule( @NotNull Callable callable, long delay, @NotNull TimeUnit unit); /** * @return A {@link CompletableScheduledFuture} representing pending completion of the task. * @see ScheduledExecutorService#scheduleAtFixedRate(Runnable, long, long, TimeUnit) * @since 4.0.0, CE 2019.1 */ @Override @NotNull CompletableScheduledFuture scheduleAtFixedRate( @NotNull Runnable command, long initialDelay, long period, @NotNull TimeUnit unit); /** * @return A {@link CompletableScheduledFuture} representing pending completion of the task. * @see ScheduledExecutorService#scheduleWithFixedDelay(Runnable, long, long, TimeUnit) * @since 4.0.0, CE 2019.1 */ @Override @NotNull CompletableScheduledFuture scheduleWithFixedDelay( @NotNull Runnable command, long initialDelay, long delay, @NotNull TimeUnit unit); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy