Documentation
¶
Overview ¶
Example: sync package overview
The ndk/sync package provides Go bindings for Android's native sync framework (sync fences / sync file descriptors).
Android sync fences are kernel-level synchronization primitives used to coordinate GPU and display operations. A sync fence represents a point in time on a GPU command stream — it signals when all commands submitted before it have completed.
Typical usage in the graphics pipeline:
- GPU driver creates a fence when submitting work
- Fence fd is passed to SurfaceFlinger / HWC
- Consumer waits on the fence before reading the buffer
- This enables pipelined rendering without CPU stalls
The sync fence API operates on file descriptors:
- sync_merge(name, fd1, fd2) — merge two fences into one
- sync_wait(fd, timeout_ms) — block until fence signals
- sync_file_info(fd) — query fence metadata
Sync fences are typically obtained from EGL (eglDupNativeFenceFD), Vulkan (vkGetFenceFdKHR), or AHardwareBuffer operations.
This program must run on an Android device.
Click to show internal directories.
Click to hide internal directories.