|
23 | 23 | import java.util.concurrent.ScheduledThreadPoolExecutor; |
24 | 24 |
|
25 | 25 | /** |
| 26 | + * <p> |
26 | 27 | * Should be used on method that must be run in a background thread. |
27 | | - * <p/> |
| 28 | + * </p> |
| 29 | + * <p> |
28 | 30 | * The annotated method MUST return void and MAY contain parameters. |
29 | | - * <p/> |
30 | | - * The generated code is based on {@link BackgroundExecutor} methods. |
31 | | - * |
| 31 | + * </p> |
| 32 | + * <p> |
| 33 | + * The generated code is based on {@link org.androidannotations.api.BackgroundExecutor} methods. |
| 34 | + * </p> |
32 | 35 | * |
33 | 36 | * <h2>Cancellation</h2> |
| 37 | + * <p> |
34 | 38 | * Since 3.0, you're able to cancel a background task by calling |
35 | 39 | * <code>BackgroundExecutor.cancelAll("id")</code> where "id" matches the |
36 | 40 | * {@link #id()} value. |
37 | 41 | * |
38 | | - * <p/> |
| 42 | + * </p> |
39 | 43 | * <blockquote> |
40 | 44 | * |
41 | 45 | * <b>Example</b> : |
|
58 | 62 | * </pre> |
59 | 63 | * |
60 | 64 | * </blockquote> |
61 | | - * <p/> |
| 65 | + * <p> |
62 | 66 | * <b>Note</b>: Cancellation may or may not be successful. If the task wasn't |
63 | 67 | * executed yet, it will be removed from the pool. But it could fail if task has |
64 | 68 | * already completed, has already been cancelled, or could not be cancelled for |
65 | 69 | * some other reason. See {@link Future#cancel(boolean)} for more information. |
66 | | - * |
| 70 | + * </p> |
67 | 71 | * |
68 | 72 | * <h2>Execution flow</h2> |
| 73 | + * <p> |
69 | 74 | * By default, all tasks will be put in a {@link ScheduledThreadPoolExecutor} |
70 | 75 | * with a core pool size of <code>2 * numberOfCpu</code>. Which means that |
71 | 76 | * background methods will be executed in <b>PARALLEL</b>. You can change this |
72 | 77 | * by calling <code>BackgroundExecutor.setExecutor(...)</code>. |
73 | | - * |
| 78 | + * </p> |
| 79 | + * <p> |
74 | 80 | * If you want execute ALL background methods SEQUENTIALLY, the best way is to |
75 | | - * change the executor of {@link BackgroundExecutor} to a |
| 81 | + * change the executor of {@link org.androidannotations.api.BackgroundExecutor} to a |
76 | 82 | * {@link ScheduledThreadPoolExecutor} with a core pool size of <code>1</code>. |
77 | | - * <p/> |
| 83 | + * </p> |
| 84 | + * <p> |
78 | 85 | * If you want execute some background methods SEQUENTIALLY, you should simply |
79 | 86 | * use {@link #serial()} field. All task with the same serial key will be |
80 | 87 | * executed sequentially. |
81 | | - * |
82 | | - * <p/> |
| 88 | + * </p> |
| 89 | + * |
83 | 90 | * <blockquote> |
84 | 91 | * |
85 | 92 | * <b>Example 1</b> (all tasks executed sequentially) : |
|
132 | 139 | * |
133 | 140 | * |
134 | 141 | * <h2>Delay</h2> |
| 142 | + * <p> |
135 | 143 | * Sometimes you may want to delay execution of a background method. To do so, |
136 | 144 | * you should use the {@link #delay()} field. |
137 | | - * <p/> |
| 145 | + * </p> |
138 | 146 | * <b>Example</b> : |
139 | | - * |
| 147 | + * |
| 148 | + * <blockquote> |
140 | 149 | * <pre> |
141 | 150 | * @EBean |
142 | 151 | * public class MyBean { |
|
152 | 161 | * |
153 | 162 | * |
154 | 163 | * @see UiThread |
155 | | - * @see BackgroundExecutor |
| 164 | + * @see org.androidannotations.api.BackgroundExecutor |
156 | 165 | */ |
157 | 166 | @Retention(RetentionPolicy.CLASS) |
158 | 167 | @Target(ElementType.METHOD) |
|
166 | 175 | * boolean mayInterruptIfRunning = true; |
167 | 176 | * BackgroundExecutor.cancelAll("my_background_id", mayInterruptIfRunning); |
168 | 177 | * </pre> |
| 178 | + * |
| 179 | + * @return the identifier for task cancellation |
169 | 180 | **/ |
170 | 181 | String id() default ""; |
171 | 182 |
|
172 | 183 | /** |
173 | 184 | * Minimum delay, in milliseconds, before the background task is executed. |
| 185 | + * |
| 186 | + * @return the minimum delay before execution |
174 | 187 | */ |
175 | 188 | int delay() default 0; |
176 | 189 |
|
|
179 | 192 | * |
180 | 193 | * All background tasks having the same <code>serial</code> will be executed |
181 | 194 | * sequentially. |
| 195 | + * |
| 196 | + * @return the serial execution group |
182 | 197 | **/ |
183 | 198 | String serial() default ""; |
184 | 199 | } |
0 commit comments