221V 3 недель назад
Сommit
503b080c5c
9 измененных файлов с 173 добавлено и 0 удалено
  1. 16 0
      .gitignore
  2. 17 0
      README.md
  3. 19 0
      comp.mk
  4. 16 0
      vtest2/.gitignore
  5. 3 0
      vtest2/Makefile
  6. 17 0
      vtest2/dub.json
  7. 10 0
      vtest2/dub.selections.json
  8. 17 0
      vtest2/source/app.d
  9. 58 0
      vtest2/source/test1.d

+ 16 - 0
.gitignore

@@ -0,0 +1,16 @@
+.dub
+docs.json
+__dummy.html
+docs/
+/vibed_test2
+vibed_test2.so
+vibed_test2.dylib
+vibed_test2.dll
+vibed_test2.a
+vibed_test2.lib
+vibed_test2-test-*
+*.exe
+*.pdb
+*.o
+*.obj
+*.lst

+ 17 - 0
README.md

@@ -0,0 +1,17 @@
+# test dlang vibe-d concurrency functions app
+
+```
+// vibe-d 0.10.2
+// vibe-core 2.11.0
+// https://code.dlang.org/packages/vibe-core
+
+$ cd <FOLDER_NAME>
+$ make c
+$ make run
+
+$ ldc2 -v
+binary    /home/e/.dlang/bin/ldc2
+version   1.39.0 (DMD v2.109.1, LLVM 18.1.6)
+config    /home/e/.dlang/etc/ldc2.conf (x86_64-unknown-linux-gnu)
+```
+

+ 19 - 0
comp.mk

@@ -0,0 +1,19 @@
+
+
+# todo clean
+
+c:
+	dub build --compiler ldc2
+
+c2:
+	dub build --compiler ldc2 --build release --force
+
+run:
+	./vtest2
+
+
+
+default: run
+
+.PHONY: c c2 run
+

+ 16 - 0
vtest2/.gitignore

@@ -0,0 +1,16 @@
+.dub
+docs.json
+__dummy.html
+docs/
+/vtest2
+vtest2.so
+vtest2.dylib
+vtest2.dll
+vtest2.a
+vtest2.lib
+vtest2-test-*
+*.exe
+*.pdb
+*.o
+*.obj
+*.lst

+ 3 - 0
vtest2/Makefile

@@ -0,0 +1,3 @@
+
+include ../comp.mk
+

+ 17 - 0
vtest2/dub.json

@@ -0,0 +1,17 @@
+{
+  "name": "vtest2",
+  "description": "test vibe-d concurrency functions app",
+  
+  "targetName": "vtest2",
+  "dflags": ["-w", "-O"],
+  "targetType": "executable",
+  "dependencies": {
+    "vibe-core": "~>2.12.0"
+  },
+  "libs": [],
+  "lflags": [],
+  
+  "license": "proprietary",
+  "copyright": "Copyright © 2025, 221V",
+  "authors": [ "221V" ]
+}

+ 10 - 0
vtest2/dub.selections.json

@@ -0,0 +1,10 @@
+{
+	"fileVersion": 1,
+	"versions": {
+		"eventcore": "0.9.36",
+		"stdx-allocator": "2.77.5",
+		"taggedalgebraic": "1.0.0",
+		"vibe-container": "1.6.2",
+		"vibe-core": "2.12.0"
+	}
+}

+ 17 - 0
vtest2/source/app.d

@@ -0,0 +1,17 @@
+
+import std.stdio;
+import std.concurrency : spawn;
+import core.time : Duration, dur;
+import core.thread;
+
+import test1 : test1_spawner;
+
+
+void main(){
+  spawn(&test1_spawner);
+  
+  Thread.sleep(dur!"seconds"(125));
+  
+  writeln("hello here!");
+}
+

+ 58 - 0
vtest2/source/test1.d

@@ -0,0 +1,58 @@
+
+alias uint8  = ubyte;
+
+import std.stdio;
+import std.concurrency : spawn;
+import core.time : Duration, dur;
+import core.thread;
+
+
+void test1_worker(uint8 n){
+  writeln("started worker = ", n);
+  
+  Thread.sleep(dur!"seconds"(120));
+  
+  writeln("stopped worker = ", n);
+}
+
+
+void test1_spawner(){
+  uint8 i = 10;
+  
+  while(i > 0){
+    spawn(&test1_worker, i);
+    
+    i--;
+  }
+}
+
+
+/*
+// 1 OS process, 10 threads
+
+> make run
+./vtest2
+started worker = 8
+started worker = 7
+started worker = 9
+started worker = 6
+started worker = 1
+started worker = 10
+started worker = 5
+started worker = 3
+started worker = 2
+started worker = 4
+stopped worker = 8
+stopped worker = 9
+stopped worker = 7
+stopped worker = 10
+stopped worker = 6
+stopped worker = 1
+stopped worker = 4
+stopped worker = 3
+stopped worker = 5
+stopped worker = 2
+hello here!
+
+*/
+