1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.request
;
15 import java
.util
.Queue
;
16 import java
.util
.concurrent
.Executor
;
17 import java
.util
.concurrent
.Executors
;
18 import java
.util
.concurrent
.LinkedBlockingQueue
;
21 * <b><u>TmfRequestExecutor</u></b>
23 * Implement me. Please.
25 public class TmfRequestExecutor
implements Executor
{
27 private final Executor fExecutor
;
28 private final Queue
<Runnable
> fRequests
= new LinkedBlockingQueue
<Runnable
>();
29 private Runnable fRequest
;
31 public TmfRequestExecutor(Executor executor
) {
35 public TmfRequestExecutor() {
36 this(Executors
.newSingleThreadExecutor());
39 public void execute(final Runnable request
) {
40 fRequests
.offer(new Runnable() {
49 if (fRequest
== null) {
54 protected synchronized void scheduleNext() {
55 if ((fRequest
= fRequests
.poll()) != null) {
56 fExecutor
.execute(fRequest
);
60 public synchronized void queueRequest(Runnable request
) {
61 fRequests
.add(request
);
This page took 0.032436 seconds and 5 git commands to generate.