Commit 1ff43a964f0e59f9f5241c22b17c92d5b68ea871

Thomas de Grivel 2024-12-04T10:40:12

wip threads, httpd

diff --git a/lib/kc3/0.1/httpd.kc3 b/lib/kc3/0.1/httpd.kc3
index 79653b1..96b422b 100644
--- a/lib/kc3/0.1/httpd.kc3
+++ b/lib/kc3/0.1/httpd.kc3
@@ -118,7 +118,7 @@ defmodule HTTPd do
     end
   }
 
-  def enable_threads = true
+  def thread_count = 1
 
   def server = fn (host, port) {
     def socket = Socket.listen(host, port)
@@ -126,10 +126,11 @@ defmodule HTTPd do
       daemonize()
       puts("KC3 HTTPd: listening on #{host}:#{port}")
       load_app()
-      if enable_threads do
-        threads = List.map(List.count(8), fn (x) {
+      if thread_count > 1 do
+        threads = List.map(List.count(thread_count - 1), fn (x) {
           Thread.new(HTTPd.server_thread)
         })
+        HTTPd.server_thread()
         List.map(threads, Thread.delete)
       else
         HTTPd.server_thread()