Skip to content

Commit 901dd9b

Browse files
committed
fix Console
1 parent 2a7d917 commit 901dd9b

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/Console.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
public class Console implements Closeable {
1616

1717
/** Print the given line. */
18-
public synchronized void out(String line) {
18+
public void out(String line) {
1919
add(line, out);
2020
}
2121

2222
/** Print the given error. */
23-
public synchronized void out(Throwable t) {
23+
public void out(Throwable t) {
2424
add(t, out);
2525
}
2626

2727
/** Print the given line. */
28-
public synchronized void err(String line) {
28+
public void err(String line) {
2929
add(line, err);
3030
}
3131

3232
/** Print the given error. */
33-
public synchronized void err(Throwable t) {
33+
public void err(Throwable t) {
3434
add(t, err);
3535
}
3636

@@ -45,7 +45,7 @@ private void add(Object o, PrintStream s) {
4545
if (nb > 5000) {
4646
// pause the thread to let time to logging
4747
try {
48-
Thread.sleep(nb > 10000 ? 400 : nb > 7500 ? 200 : 100);
48+
Thread.sleep(nb > 10000 ? 200 : nb > 7500 ? 100 : 25);
4949
} catch (InterruptedException e) {
5050
// ignore
5151
}

net.lecousin.core/src/main/java/net/lecousin/framework/log/LoggerThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void log(Appender appender, Log log) {
6666
if (s > 5000) {
6767
// pause the thread to let time to logging
6868
try {
69-
Thread.sleep(s > 10000 ? 400 : s > 7500 ? 200 : 100);
69+
Thread.sleep(s > 10000 ? 250 : s > 7500 ? 100 : 50);
7070
} catch (InterruptedException e) {
7171
// ignore
7272
}

net.lecousin.core/src/main/java/net/lecousin/framework/memory/ArrayCache.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.LinkedList;
66
import java.util.List;
77

8+
import net.lecousin.framework.application.LCCore;
89
import net.lecousin.framework.collections.TurnArray;
910
import net.lecousin.framework.collections.sort.RedBlackTreeInteger;
1011
import net.lecousin.framework.collections.sort.RedBlackTreeInteger.Node;
@@ -72,8 +73,10 @@ private static class ArraysBySize<T> {
7273

7374
private RedBlackTreeInteger<ArraysBySize<T>> arraysBySize = new RedBlackTreeInteger<>();
7475
private int totalSize = 0;
76+
private boolean debug;
7577

7678
protected ArrayCache() {
79+
debug = LCCore.getApplication().isDebugMode();
7780
MemoryManager.register(this);
7881
}
7982

@@ -131,6 +134,8 @@ public void free(T array) {
131134
return;
132135
}
133136
ArraysBySize<T> arrays = node.getElement();
137+
if (debug && arrays.arrays.contains(array))
138+
throw new IllegalStateException("Array already in cache!");
134139
arrays.lastCachedTime = System.currentTimeMillis();
135140
if (arrays.arrays.isFull()) return;
136141
totalSize += len;

net.lecousin.core/src/main/java/net/lecousin/framework/util/HierarchyProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.function.Consumer;
55

66
import net.lecousin.framework.concurrent.async.AsyncSupplier;
7+
import net.lecousin.framework.concurrent.threads.Task.Priority;
78

89
/**
910
* Generic interface to navigate in a hierarchy.
@@ -49,10 +50,10 @@ public static interface Asynchronous<ElementType> {
4950
boolean mayHaveChildren(ElementType element);
5051

5152
/** Return true if the given element has children. */
52-
AsyncSupplier<Boolean,Exception> hasChildren(ElementType element, boolean refresh, byte priority);
53+
AsyncSupplier<Boolean,Exception> hasChildren(ElementType element, boolean refresh, Priority priority);
5354

5455
/** Return the children of the given element. */
55-
AsyncSupplier<List<? extends ElementType>,Exception> getChildren(ElementType element, boolean refresh, byte priority);
56+
AsyncSupplier<List<? extends ElementType>,Exception> getChildren(ElementType element, boolean refresh, Priority priority);
5657
}
5758

5859
}

0 commit comments

Comments
 (0)