diff options
author | Simon Rettberg | 2019-11-13 17:09:02 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-11-13 17:09:02 +0100 |
commit | 642b82d0eabd6356713af172aea7ca51e7f3fb57 (patch) | |
tree | c5fac8d0d97362e48a5dc5770c759fa4c3d0f03f /api | |
parent | Add isFinished() to Task (diff) | |
download | taskman-lite-642b82d0eabd6356713af172aea7ca51e7f3fb57.tar.gz taskman-lite-642b82d0eabd6356713af172aea7ca51e7f3fb57.tar.xz taskman-lite-642b82d0eabd6356713af172aea7ca51e7f3fb57.zip |
BoundedLog type + serializer
Diffstat (limited to 'api')
-rw-r--r-- | api/src/main/java/org/openslx/taskmanager/api/BoundedLog.java | 25 |
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(); + } + } + +} |