Skip to content

Commit 850a967

Browse files
committed
cleanup(todo,docs): added note about ctx names.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
1 parent d98abed commit 850a967

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

TODO.md

-20
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,6 @@
22

33
### TODO
44

5-
#### Ctx
6-
7-
- [x] store ctxs in thread local storage (pthread_setspecific API)? https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_key_create.html `__find_thread_by_id` and loop over /proc/self/task? -> https://stackoverflow.com/questions/3707358/get-all-the-thread-id-created-with-pthread-created-within-an-process
8-
- [ ] we could then drop: (since every context is thread specific data)
9-
- - [x] global ctx map and mutex
10-
- - [x] m_mod_ctx() api
11-
- - [x] m_ctx_ref() api
12-
- - [x] m_mod_ref() api should become m_mod_lookup() and let users manage its lifecyle (ie: m_mem_ref it if needed)
13-
- - [x] drop m_ctx_t param from ctx.h API
14-
- - [x] drop m_ctx_t forward declaration as it is now invisible to user
15-
- - [x] drop M_CTX_ZOMBIE
16-
- - [x] properly enforce that a module API cannot be called when m_ctx() != mod->ctx (ie: if you pass a module around between threads/contexts)
17-
- - [x] drop libmodule_init() and deinit() constructors
18-
- - [x] move ctor defines into mod_easy.h
19-
- - [x] drop m_on_boot(); specify that mod_easy API force-uses malloc,calloc and free by default.
20-
- - [x] Specify that m_set_memhook should be called before allocating any libmodule related resource
21-
- [x] and just add an m_ctx() API that returns ctx associated with current thread
22-
- [x] store in ctx a `curr_mod` that points to the module whose callback is currently being processed, if any, or NULL; when NULL; we are outside a module callback, therefore we can return it; else, we must guarantee that module has permissions to access its ctx
23-
- [ ] Downside: how could we guarantee that 2 ctx with same name do not exist? We cannot; is this a limitation, actually?
24-
255
#### DOC
266

277
- [x] Fully rewrite documentation per-namespace

docs/concepts/ctx.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ A context can be seen as a collector for modules. You can loop on events from ea
44
It is stored as a [thread specific object](https://linux.die.net/man/3/pthread_setspecific), created through `m_ctx_register` and deleted through `m_ctx_deregister`.
55
This can be particularly useful when dealing with 2+ threads; each thread has its own module's context and thus its own events to be polled.
66
Modules can only see and reach (through PubSub messaging) other modules from same context.
7+
A context is given a name at registration time. This is only useful for logging purposes.
8+
9+
> NOTE: having multiple contexts with same name is allowed; given that each context is thread-specific, there will be no clash.
10+
> Of course, it's better to set different names.
711
812
## Loop
913

0 commit comments

Comments
 (0)