com.liferay.portal.background.task.internal.BackgroundTaskInExecutionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.portal.background.task.service
Show all versions of com.liferay.portal.background.task.service
Liferay Portal Background Task Service
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.portal.background.task.internal;
import com.liferay.petra.lang.SafeCloseable;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Dante Wang
*/
public class BackgroundTaskInExecutionUtil {
public static boolean isInExecution(long backgroundTaskId) {
return _backgroundTaskIds.contains(backgroundTaskId);
}
public static SafeCloseable setInExecutionWithSafeCloseable(
long backgroundTaskId) {
_backgroundTaskIds.add(backgroundTaskId);
return () -> _backgroundTaskIds.remove(backgroundTaskId);
}
private static final Set _backgroundTaskIds =
Collections.newSetFromMap(new ConcurrentHashMap<>());
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy