1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.utils.threads.ua;
14 import java.util.Collection;
17 * Worker executes tasks.
19 * Hint! To execute work synchronously use: <BR>
20 * Worker.asyncExec(runnable, null).waitForState(WorkState.FINAL_STATES);
22 * To cancel all work get the work with getQueuedWork() and invoke cancel() to each.
24 * @see SynchronizedWorker
26 * @author Toni Kalajainen (toni.kalajainen@vtt.fi)
28 public interface Worker extends StatefulExecutor {
31 * Execute work (async).
34 * @param initialListener listener initially set on monitor object or null
35 * @return async work monitor object
37 WorkMonitor asyncExec(Runnable runnable, StateListener<WorkState> initialListener)
38 throws WorkerClosedException;
41 * Get a list of all queued work.
42 * @param result queued work.
44 void getQueuedWork(Collection<WorkMonitor> result);