1 /* 2 * Javolution - Java(TM) Solution for Real-Time and Embedded Systems 3 * Copyright (C) 2006 - Javolution (http://javolution.org/) 4 * All rights reserved. 5 * 6 * Permission to use, copy, modify, and distribute this software is 7 * freely granted, provided that this notice is preserved. 8 */ 9 package javolution.context; 10 11 /** 12 * <p> This interface represents an executor (typically a thread) 13 * capable of executing a task concurrently.</p> 14 * 15 * @author <a HREF="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a> 16 * @version 4.2, December 14, 2006 17 */ 18 public interface ConcurrentExecutor extends Runnable { 19 20 /** 21 * Executes the specified logic concurrently if it can be done immediately. 22 * 23 * @param logic the logic to be executed. 24 * @param status the status object to be notified during the course of the 25 * concurrent execution. 26 * @return <code>true</code> if this concurrent executor will execute 27 * the specified task; <code>false</code> otherwise. 28 */ 29 boolean execute(Runnable logic, Status status); 30 31 /** 32 * Terminates this executor once the last pending concurrent execution is 33 * completed. 34 */ 35 void terminate(); 36 37 /** 38 * This interface represents the status notification of a concurrent 39 * execution. 40 */ 41 interface Status { 42 43 /** 44 * This method is called when the concurrent execution is started. 45 */ 46 void started(); 47 48 /** 49 * This method is called when the concurrent execution is completed. 50 */ 51 void completed(); 52 53 /** 54 * This method is called when an exception has been raised during 55 * the concurrent execution. 56 */ 57 void error(Throwable error); 58 59 } 60 }