diff app/src/main/java/com/bartsent/simpleresizer/lib/ThreadPools.kt @ 18:eedf995462d9 concur2

Parallalized, but ConstraintLayout started hosing the edit window.
author David Barts <n5jrn@me.com>
date Mon, 22 Feb 2021 07:04:31 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/bartsent/simpleresizer/lib/ThreadPools.kt	Mon Feb 22 07:04:31 2021 -0800
@@ -0,0 +1,13 @@
+package com.bartsent.simpleresizer.lib
+
+import java.util.concurrent.Executors
+
+/**
+ * Thread pools. We use just one, and it is sized to the maximum responsible thread use,
+ * which is one more than the number of cores. This is because when scaling, we have one
+ * worker thread sitting around and waiting for the remaining busy ones to finish.
+ */
+object ThreadPools {
+    val NWORKERS = Runtime.getRuntime().availableProcessors() + 1
+    val WORKERS = Executors.newFixedThreadPool(NWORKERS)
+}
\ No newline at end of file