Make use of Java 21 virtual threads in GlobalThreadPool

This commit is contained in:
0xb00bface 2023-12-30 21:51:52 +01:00
parent 3d6229ec13
commit 55f9093d62
4 changed files with 10 additions and 7 deletions

View File

@ -8,6 +8,7 @@
* Made sure, that @winkru's fix to faster check, if a Chaturbate model is * Made sure, that @winkru's fix to faster check, if a Chaturbate model is
online is merged correctly into my codebase. This should reduce 429 errors online is merged correctly into my codebase. This should reduce 429 errors
and speed up the online check quite a bit. and speed up the online check quite a bit.
* Java 21 is now required
* Changes by @WinkRU * Changes by @WinkRU
* Added setting to restrict recording by bit rate * Added setting to restrict recording by bit rate
* Added setting to use the shortest side to restrict the resolution * Added setting to use the shortest side to restrict the resolution

View File

@ -25,7 +25,7 @@ public abstract class MyFreeCamsAbstractUpdateService extends PaginatedScheduled
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} catch (Exception e) { } catch (Exception e) {
log.debug("Couldn't update model on line state", e); log.debug("Couldn't update model online state", e);
} }
}); });
} }

View File

@ -1,16 +1,18 @@
package ctbrec; package ctbrec;
import lombok.extern.slf4j.Slf4j; import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
@Slf4j
public class GlobalThreadPool { public class GlobalThreadPool {
private static final ExecutorService threadPool = Executors.newWorkStealingPool(); private static final ExecutorService threadPool = Executors.newThreadPerTaskExecutor(r -> Thread
.ofVirtual()
.name("GlobalWorker-" + UUID.randomUUID().toString().substring(0, 8))
.unstarted(r)
);
private GlobalThreadPool() { private GlobalThreadPool() {
} }

View File

@ -16,8 +16,8 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>21</maven.compiler.target>
<version.javafx>21.0.1</version.javafx> <version.javafx>21.0.1</version.javafx>
<version.junit>5.7.2</version.junit> <version.junit>5.7.2</version.junit>
<jackson.version>2.15.1</jackson.version> <jackson.version>2.15.1</jackson.version>