Browse Source

Start setting up TaskSystem module

The hope is that this will make multithreaded code radically easier to
write. I need this already for file-helper.
master
Macoy Madson 2 months ago
parent
commit
54b0dcb347
  1. 31
      src/TaskSystem.cake
  2. 5
      test/src/GameLibTests.cake

31
src/TaskSystem.cake

@ -0,0 +1,31 @@
;; TaskSystem.cake: Interface into task-based multithreading
(c-import "TaskScheduler_c.h")
(defun remove-me ())
;;
;; Building
;;
(add-dependency-git-submodule clone-enkiTS
"https://github.com/dougbinks/enkiTS"
"Dependencies/enkiTS")
(add-c-search-directory-module "Dependencies/enkiTS/src")
(add-cpp-build-dependency "TaskScheduler.cpp" "TaskScheduler_c.cpp")
(comptime-cond
('Unix
(add-library-dependency "pthread"))) ;; Enki's interface to threads on Linux
;;
;; Tests
;;
(comptime-cond
('auto-test
(c-import "stdio.h")
(defun-nodecl test--task-systems (&return int)
(var task-scheduler (* enkiTaskScheduler) (enkiNewTaskScheduler))
(enkiInitTaskScheduler task-scheduler)
(fprintf stderr "Created %d threads\n" (enkiGetNumTaskThreads task-scheduler))
(enkiWaitforAllAndShutdown task-scheduler)
(enkiDeleteTaskScheduler task-scheduler)
(return 0))))

5
test/src/GameLibTests.cake

@ -49,10 +49,11 @@
(cond
(test-minimal
(gamelib-run-test
"Auto Test (data structures only)"
"Auto Test (somewhat minimal)"
(array platform-config
"../src/AutoTest.cake" "../src/Introspection.cake"
"../src/Dictionary.cake" "../src/DynamicArray.cake")))
"../src/Dictionary.cake" "../src/DynamicArray.cake"
"../src/TaskSystem.cake")))
(test-opengl-only
(gamelib-run-test

Loading…
Cancel
Save