summaryrefslogtreecommitdiff
path: root/src/main/java/org/mamago/util/Bits.java
diff options
context:
space:
mode:
authorManuel Amago <mamago@gmail.com>2019-09-08 15:12:16 +0100
committerManuel Amago <mamago@gmail.com>2019-09-08 15:12:16 +0100
commit5bf90d1008a7d40558740a7c863d7094b423424a (patch)
tree60507add81163760379dfe10f7fe9fdecb11a0d2 /src/main/java/org/mamago/util/Bits.java
parent980b7c9fa9a88f7ee3881a4a3c65015da068eb2c (diff)
downloadlogging-5bf90d1008a7d40558740a7c863d7094b423424a.tar.gz
logging-5bf90d1008a7d40558740a7c863d7094b423424a.zip
Convert to write to a "shared ring buffer".HEADmaster
First steps, not actually fully functional yet (i.e. ring buffer is not actually a ring buffer, and there is no log printer polling the other side).
Diffstat (limited to 'src/main/java/org/mamago/util/Bits.java')
-rw-r--r--src/main/java/org/mamago/util/Bits.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/org/mamago/util/Bits.java b/src/main/java/org/mamago/util/Bits.java
new file mode 100644
index 0000000..4672ea9
--- /dev/null
+++ b/src/main/java/org/mamago/util/Bits.java
@@ -0,0 +1,16 @@
+package org.mamago.util;
+
+public class Bits {
+ // Prevent instantiation
+ private Bits() {}
+
+ public static int roundUpToLongSize(int size) {
+ return roundUpToSize(size, 8);
+ }
+
+ public static int roundUpToSize(int size, int width) {
+ // Formula:
+ // (size + w) / w * w; // Adding w rounds up to the next whole width
+ return ((size + width) / width) * width;
+ }
+}