mi-malloc: Subprocesses

| mi-malloc 1.8/2.1 |

Loading...
Searching...
No Matches
Typedefs | Functions
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.

## Detailed Description

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).

## Typedef Documentation

## ◆ 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 `true` to keep visiting. Returning `false` will 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.

## Function Documentation

## ◆ 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 `subproc`
  arg | A user argument that is passed to each visitor function call. Return `true` if all heaps are visited (and false otherwise).