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