progress on setting up host/client api process execution

This commit is contained in:
2025-10-12 16:20:08 -04:00
parent 866432723e
commit 406ff97968
6 changed files with 72 additions and 13 deletions

View File

@@ -1,8 +1,9 @@
package sectr
import "base:runtime"
import c "core:c/libc"
// import "base:runtime"
// import c "core:c/libc"
import "core:dynlib"
import "core:sync"
Path_Assets :: "../assets/"
Path_Shaders :: "../shaders/"
@@ -12,8 +13,9 @@ ModuleAPI :: struct {
lib: dynlib.Library,
// write-time: FileTime,
startup: type_of( startup ),
hot_reload: type_of( hot_reload ),
startup: type_of( startup ),
hot_reload: type_of( hot_reload ),
tick_lane_startup: type_of( tick_lane_startup),
}
StartupContext :: struct {}
@@ -24,12 +26,46 @@ startup :: proc(host_mem: ^HostMemory, thread_mem: ^ThreadMemory)
dummy : int = 0
dummy += 1
memory = host_mem
thread_wide_startup()
}
thread_wide_startup :: proc()
{
if thread_memory.id == .Master_Prepper
{
thread_memory.live_lanes =
tick_lane_startup() //
}
// TODO(Ed): Spawn helper thraed, then prepp both live threads
memory.state.live_threads += 1; // Atomic_Accountant
memory.host_api.launch_live_thread()
}
@export
tick_lane_startup :: proc(thread_mem: ^ThreadMemory)
{
memory.state.live_threads += 1
tick_lane()
}
tick_lane :: proc()
{
dummy : int = 0
for ;;
{
dummy += 1
if thread_memory.index == .Master_Prepper
{
memory.host_api.sync_client_api()
}
}
}
@export

View File

@@ -1,15 +1,19 @@
package sectr
import "core:sync"
HostMemory :: struct {
host_scratch: [256 * Kilo]byte,
client_api_sync_lock: sync.Benaphore,
client_api: ModuleAPI,
client_memory: ^State,
host_api: Host_API,
}
Host_API :: struct {
launch_thread: #type proc(),
launch_live_thread: #type proc(),
request_virtual_memory: #type proc(),
request_virtual_mapped_io: #type proc(),
@@ -19,4 +23,5 @@ Host_API :: struct {
ThreadMemory :: struct {
using _: ThreadWorkerContext,
live_lanes: int,
}

View File

@@ -42,8 +42,8 @@ JobSystemContext :: struct {
ThreadWorkerContext :: struct {
system_ctx: Thread,
index: WorkerID,
}
id: WorkerID,
}
WorkerID :: enum int {
Master_Prepper = 0,

View File

@@ -1,8 +1,14 @@
package sectr
// This should be the only global on client module side.
host_memory: ^HostMemory
memory: ^HostMemory
@(thread_local)
thread_memory: ^ThreadMemory
THREAD_TICK_LANES :: 2
State :: struct {
live_threads: int,
job_system: JobSystemContext,
}