summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/main/java/org/openslx/taskmanager/api/BoundedLog.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/api/src/main/java/org/openslx/taskmanager/api/BoundedLog.java b/api/src/main/java/org/openslx/taskmanager/api/BoundedLog.java
new file mode 100644
index 0000000..86b8343
--- /dev/null
+++ b/api/src/main/java/org/openslx/taskmanager/api/BoundedLog.java
@@ -0,0 +1,25 @@
+package org.openslx.taskmanager.api;
+
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class BoundedLog extends LinkedBlockingQueue<String>
+{
+ private static final long serialVersionUID = -5425030291381563963L;
+
+ public final boolean implicitNewlines;
+
+ public BoundedLog( int capacity, boolean implicitNewlines )
+ {
+ super( capacity );
+ this.implicitNewlines = implicitNewlines;
+ }
+
+ public void addLog( String data )
+ {
+ while ( !this.offer( data ) ) {
+ // Throw away oldest entry and try again
+ this.poll();
+ }
+ }
+
+}