Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/SerializedTaskQueue.java')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/SerializedTaskQueue.java58
1 files changed, 0 insertions, 58 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/SerializedTaskQueue.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/SerializedTaskQueue.java
deleted file mode 100644
index 4226421a9..000000000
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/SerializedTaskQueue.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- ******************************************************************************/
-package org.eclipse.osgi.internal.log;
-
-import java.util.LinkedList;
-
-/**
- * SerializedTaskQueue is a utility class that will allow asynchronous but serialized execution of tasks
- */
-public class SerializedTaskQueue {
-
- private static final int MAX_WAIT = 5000;
- private final LinkedList<Runnable> tasks = new LinkedList<>();
- private Thread thread;
- private final String queueName;
-
- public SerializedTaskQueue(String queueName) {
- this.queueName = queueName;
- }
-
- public synchronized void put(Runnable newTask) {
- tasks.add(newTask);
- if (thread == null) {
- thread = new Thread(queueName) {
- public void run() {
- Runnable task = nextTask(MAX_WAIT);
- while (task != null) {
- task.run();
- task = nextTask(MAX_WAIT);
- }
- }
- };
- thread.start();
- } else
- notify();
- }
-
- synchronized Runnable nextTask(int maxWait) {
- if (tasks.isEmpty()) {
- try {
- wait(maxWait);
- } catch (InterruptedException e) {
- // ignore -- we control the stack here and do not need to propagate it.
- }
-
- if (tasks.isEmpty()) {
- thread = null;
- return null;
- }
- }
- return tasks.removeFirst();
- }
-}

Back to the top