Browse Source

add simplethreadpool package (#1595)

* add threadpool package

* rename package

* remove spaces from cpp testing snippets

* Update xmake.lua

* Update xmake.lua

Co-authored-by: ruki <[email protected]>
Romain Chardiny 2 years ago
parent
commit
1a8a467fe1
1 changed files with 39 additions and 0 deletions
  1. 39 0
      packages/s/simplethreadpool/xmake.lua

+ 39 - 0
packages/s/simplethreadpool/xmake.lua

@@ -0,0 +1,39 @@
+package("simplethreadpool")
+    set_homepage("https://github.com/romch007/simplethreadpool")
+    set_description("Simple thread pooling library in C++")
+    set_license("MIT")
+
+    add_urls("https://github.com/romch007/simplethreadpool.git")
+
+    add_versions("2022.11.18", "e0eabdf732394a810f1dd1eeec0efee4954bf5b7")
+
+    if is_plat("linux", "bsd") then
+        add_syslinks("pthread")
+    end
+
+    on_load(function (package)
+        if not package:config("shared") then
+            package:add("defines", "SIMPLETHREADPOOL_STATIC")
+        end
+    end)
+
+    on_install("linux", "macosx", "windows", "bsd", "android", "iphoneos", "cross", function (package)
+        local configs = {}
+        configs.kind = package:config("shared") and "shared" or "static"
+        import("package.tools.xmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+          void test() {
+            simplethreadpool::pool p;
+            int counter = 0;
+            p.push([&] {
+                counter++;
+            });
+            p.start();
+            while (p.busy());
+          }
+        ]]}, {configs = {languages = "c++17"}, includes = "simplethreadpool/pool.hpp"}))
+    end)
+