package org.springblade.common.utils;

import java.util.concurrent.Callable;

/**
 * 异步任务
 *
 * @param <T>
 */
public class AsynTaskCallable<T> implements Callable<T> {
	private String taskId;

	private Callable<T> task;

	public AsynTaskCallable(String taskId, Callable<T> task) {
		this.taskId = taskId;
		this.task = task;
	}

	@Override
	public T call() throws Exception {
		T callResult = task.call();
		TaskResult result = new TaskResult();
		result.setTaskId(taskId);
		result.setData(callResult);
		return (T) result;
	}

}
