summaryrefslogtreecommitdiff
path: root/src/modules/stars/stars.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-01-10 15:09:29 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-01-10 23:50:57 -0800
commit19966a5cb3a8d9cf8edbae225953da042dadfa96 (patch)
treefd041758fb8f7301d2d699faa420ea80d5fc08e0 /src/modules/stars/stars.c
parentcffc3da34523b996393f730bed5a65934b499167 (diff)
*: introduce paths for module contexts
There needs to be a way to address module context instances by name externally, in a manner complementary to settings and taps. This commit adds a string-based path to til_module_context_t, and modifies til_module_create_context() to accept a parent path which is then concatenated with the name of the module to produce the module instance's new path. The name separator used in the paths is '/' just like filesystem paths, but these paths have no relationship to filesystems or files. The root module context creation in rototiller's main simply passes "" as the parent path, resulting in a "/" root as one would expect. There are some obvious complications introduced here however: - checkers in particular creates a context per cpu, simply using the same seed and setup to try make the contexts identical at the same ticks value. With this commit I'm simply passing the incoming path as the parent for creating those contexts, but it's unclear to me if that will work OK. With an eye towards taps deriving their parent path from the context path, I guess these taps would all get the same parent and hash to the same value despite being duplicated. Maybe it Just Works, but one thing is clear - there won't be any way to address the per-cpu taps as-is. Maybe that's desirable though, there's probably not much use in trying to control the taps at the CPU granularity. - when the recursive settings stuff lands, it should bring along the ability to explicitly name settings blocks. Those names should override the module name in constructing the path. I've noted as such in the code. - these paths probably need to be hashed @ initialization time so there needs to be a hash function added to til, and a hash value accompanying the name in the module context. It'd be dumb to keep recomputing the hash when these paths get used for hash table lookups multiple times per frame... there's probably more I'm forgetting right now, but this seems like a good first step. fixup root path
Diffstat (limited to 'src/modules/stars/stars.c')
-rw-r--r--src/modules/stars/stars.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index 12de4ed..e8a2f18 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -69,7 +69,7 @@ float get_random_unit_coord(unsigned *seed) {
}
-static til_module_context_t * stars_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * stars_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
stars_context_t *ctxt;
float z;
@@ -78,7 +78,7 @@ static til_module_context_t * stars_create_context(unsigned seed, unsigned ticks
if (!setup)
setup = &stars_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(stars_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(stars_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
© All Rights Reserved