mi-malloc: Subprocesses
A sub-process contains its own arena's and heaps that are fully separate from the main (sub) process. More...
Typedefs | |
| typedef void * | mi_subproc_id_t |
| A process can associate threads with sub-processes. | |
| typedef bool | mi_heap_visit_fun(mi_heap_t *heap, void *arg) |
| The type of a heap visitor function. | |
Functions | |
| mi_subproc_id_t | mi_subproc_main (void) |
| Get the main sub-process identifier. | |
| mi_subproc_id_t | mi_subproc_current (void) |
| Get the current sub-process identifier of this thread. | |
| mi_subproc_id_t | mi_subproc_new (void) |
| Create a fresh sub-process (with no associated threads yet). | |
| void | mi_subproc_destroy (mi_subproc_id_t subproc) |
| v3: Destroy a previously created sub-process. | |
| void | mi_subproc_delete (mi_subproc_id_t subproc) |
| v1,v2: Delete a previously created sub-process. | |
| void | mi_subproc_add_current_thread (mi_subproc_id_t subproc) |
| Add the current thread to the given sub-process. | |
| bool | mi_subproc_visit_heaps (mi_subproc_id_t subproc, mi_heap_visit_fun *visitor, void *arg) |
| Visit all heaps belonging to a subprocess. | |
A sub-process contains its own arena's and heaps that are fully separate from the main (sub) process.
A thread can belong to only one subprocess at a time. This can be used to separate out logically separate parts of a program (like running multiple interpreter instances in CPython).
◆ mi_heap_visit_fun
typedef bool mi_heap_visit_fun(mi_heap_t *heap, void *arg)
The type of a heap visitor function.
- Returns
- Return
trueto keep visiting. Returningfalsewill stop visiting further heaps.
◆ mi_subproc_id_t
typedef void* mi_subproc_id_t
A process can associate threads with sub-processes.
Sub-processes are isolated and will not reclaim or visit memory from other sub-processes. Each subprocess always has an associated main heap.
◆ mi_subproc_add_current_thread()
| void mi_subproc_add_current_thread | ( | mi_subproc_id_t | subproc | ) |
Add the current thread to the given sub-process.
This should be called right after a thread is created (and no allocation has taken place yet).
◆ mi_subproc_current()
| mi_subproc_id_t mi_subproc_current | ( | void | ) |
Get the current sub-process identifier of this thread.
◆ mi_subproc_delete()
| void mi_subproc_delete | ( | mi_subproc_id_t | subproc | ) |
v1,v2: Delete a previously created sub-process.
- Parameters
-
subproc The sub-process identifier. Only delete sub-processes if all associated threads have terminated.
- See also
- mi_subproc_destroy()
◆ mi_subproc_destroy()
| void mi_subproc_destroy | ( | mi_subproc_id_t | subproc | ) |
v3: Destroy a previously created sub-process.
- Parameters
-
subproc The sub-process identifier. Only destroy sub-processes if all associated threads have terminated.
◆ mi_subproc_main()
| mi_subproc_id_t mi_subproc_main | ( | void | ) |
Get the main sub-process identifier.
◆ mi_subproc_new()
| mi_subproc_id_t mi_subproc_new | ( | void | ) |
Create a fresh sub-process (with no associated threads yet).
- Returns
- The new sub-process identifier.
◆ mi_subproc_visit_heaps()
| bool mi_subproc_visit_heaps | ( | mi_subproc_id_t | subproc, |
| mi_heap_visit_fun * | visitor, | ||
| void * | arg ) |
Visit all heaps belonging to a subprocess.
- Parameters
-
subproc The subprocess that the heaps should belong to visitor The visitor function is called with each heap in subprocarg A user argument that is passed to each visitor function call. Return trueif all heaps are visited (and false otherwise).