]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ua/Worker.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.thread / src / org / simantics / utils / threads / ua / Worker.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.utils.threads.ua;
13
14 import java.util.Collection;
15
16 /**
17  * Worker executes tasks. 
18  * <p>
19  * Hint! To execute work synchronously use: <BR>
20  *  Worker.asyncExec(runnable, null).waitForState(WorkState.FINAL_STATES);
21  * <p>
22  * To cancel all work get the work with getQueuedWork() and invoke cancel() to each.
23  * 
24  * @see SynchronizedWorker
25  * @see ThreadPool
26  * @author Toni Kalajainen (toni.kalajainen@vtt.fi)
27  */
28 public interface Worker extends StatefulExecutor {
29         
30         /**
31          * Execute work (async).
32          * 
33          * @param runnable
34          * @param initialListener listener initially set on monitor object or null
35          * @return async work monitor object
36          */
37         WorkMonitor asyncExec(Runnable runnable, StateListener<WorkState> initialListener)
38         throws WorkerClosedException;
39
40         /**
41          * Get a list of all queued work.
42          * @param result queued work.
43          */
44         void getQueuedWork(Collection<WorkMonitor> result);
45
46 }