Skip to content

docs: add thread safety documentation to C API functions in ghostty.h #182

@daiimus

Description

@daiimus

Summary

Out of ~80+ exported C API functions in ghostty.h, only 2 have any thread safety documentation (ghostty_surface_write_output in Zig, and ghostty_surface_tmux_detach mentioning "Safe to call from any thread").

Functions like ghostty_surface_draw, ghostty_surface_set_size, ghostty_surface_set_focus, ghostty_surface_text, ghostty_surface_key, etc. all have implicit requirements about being called from specific threads, but this is never stated.

What's Needed

For each exported function, document:

  1. Which thread(s) it can be called from (main thread, IO thread, any thread)
  2. Which functions conflict with each other (cannot be called concurrently)
  3. Data lifetime for pointer parameters and return values
  4. Whether the function blocks or is async

Severity

MEDIUM — The iOS embedder must guess threading requirements. Mistakes cause subtle data races.

Source

Identified during code review of daiimus/ghostty:ios-external-backend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationp3-lowCosmetic, noisy logs, minor polishzig-forkRequires Ghostty fork changes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions