cpp-static-thread-safety
Skill21k starsChanged 3 years agoApache-2.0View on GitHub
Enforce C++ static thread safety annotations and correct synchronization primitives. Use this skill when designing multi-threaded classes or editing guarded member fields.
Trending
More talk lately.about the whole repository
Who's talking about google/filament
- @romainguy.dev“Android XR was unveiled today! You can download the preview SDK today and start using the Compose and …”Bluesky · Dec 12, 2024 · 131 likes
- godotengine/godot“[DRAFT] A Collection of Scene Shader Fixes”GitHub · Dec 13, 2024 · 44 reactions
- godotengine/godot“Properly conserve energy when calculating ambient lighting.”GitHub · Sep 11, 2026 · 12 reactions
- glfw/glfw“Use sRGB colour space by default on macOS”GitHub · Jul 26, 2025 · 5 reactions
- conan-io/conan-center-index“[request] filament/1.12.0”GitHub · Aug 18, 2021 · 4 reactions
The biggest 5 of 43 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 43
Talked about on GitHub, Bluesky and Hacker News (43 times).
On GitHub · 38
- Dec 13, 2024[DRAFT] A Collection of Scene Shader Fixes — godotengine/godot44 reactions · 4 comments
- Sep 11, 2026Properly conserve energy when calculating ambient lighting. — godotengine/godot12 reactions · 4 comments
- Jul 26, 2025Use sRGB colour space by default on macOS — glfw/glfw5 reactions · 1 comment
- Aug 18, 2021[request] filament/1.12.0 — conan-io/conan-center-index4 reactions · 1 comment
- May 13, 2024Add emissive_exposure_weight to the StandardMaterial — bevyengine/bevy2 reactions · 1 comment
33 more on GitHub
- Jan 15, 2022Use amount and perceptual roughness constants from Filament. — godotengine/godot2 reactions · 12 comments
- Aug 13, 2026📝 Record initial configured-source skill reviews — CypherPoet/custom-agent-skills1 reaction
- Mar 8, 2026TASK-010: Cross-Platform Sample App — matt-goldman/filament1 reaction
- Mar 8, 2026TASK-006: iOS Objective-C++ Wrapper Framework — matt-goldman/filament1 reaction
- Mar 9, 2025Renderer API — google-deepmind/mujoco1 reaction · 13 comments
- Aug 20, 2024volume — galacean/engine1 reaction · 8 comments
- Jun 14, 2024Include extended asset loader android — Fieldwire/filament1 reaction
- May 5, 2024wanted: filament — bazelbuild/bazel-central-registry1 reaction
- Dec 25, 2022The reference information regarding the use of cgltf_load_buffer_base64 is unclear — jkuhlmann/cgltf1 reaction
- Jun 13, 2022Fixed synchronization of 3D scene state and camera frames using Frame.getCameraTextureName — sceneview/sceneview1 reaction
- Apr 8, 2022__Pyx_KwValues_FASTCALL: avoid triggering UB by adding non-zero to NULL (caught by UBSAN nullptr-with-nonzero-offset) — cython/cython1 reaction · 2 comments
- Oct 5, 2021RFC: Renderer Upgrade Project — vircadia/vircadia-native-core1 reaction · 25 comments
- Dec 2, 2020[New Port Request] filament — microsoft/vcpkg1 reaction · 1 comment
- Aug 26, 2020test for triangle winding / mirroring via negative determinant — KhronosGroupArchives/glTF-Sample-Models1 reaction · 3 comments
- Oct 31, 2019Implement physically based rendering (PBR) — OpenXRay/xray-161 reaction · 1 comment
- Mar 20, 2019Feature request: Human friendly Camera API for SceneView — google-ar/sceneform-android-sdk1 reaction · 2 comments
- Feb 18, 2019Add Khronos glTF sample models to fidelity test suite — google/model-viewer1 reaction · 3 comments
- Oct 15, 2018Someone should try making this run on Apple — andrewrk/zig-vulkan-triangle1 reaction · 3 comments
- Oct 23, 2026build(deps): bump the maven group across 1 directory with 20 updates — peo1108/Cam-Kernel-SU0 reactions · 1 comment
- Oct 17, 2026build(deps): bump com.google.android.filament:filament-android from 1.77.0 to 1.77.3 — daanbouwman19/flight-planner-android0 reactions
- Oct 3, 2026build(deps): bump com.google.android.filament:filament-android from 1.77.0 to 1.77.1 — daanbouwman19/flight-planner-android0 reactions · 1 comment
- Sep 28, 2026Bump com.google.android.filament:filament-android from 1.66.0 to 1.77.1 — yossfu/Ephora-Viewer0 reactions
- Sep 28, 2026Bump com.google.android.filament:filament-utils-android from 1.66.0 to 1.77.1 — yossfu/Ephora-Viewer0 reactions · 1 comment
- Sep 26, 2026build(deps): bump com.google.android.filament:filament-android from 1.76.1 to 1.77.0 — daanbouwman19/flight-planner-android0 reactions
- Sep 19, 2026build(deps): bump com.google.android.filament:filament-android from 1.75.1 to 1.76.1 — daanbouwman19/flight-planner-android0 reactions
- Sep 19, 2026Adds OSS-Fuzz project for Google Filament (https://github.com/google/filament). — google/oss-fuzz0 reactions · 2 comments
- Aug 29, 2026build(deps): bump filament from 1.75.0 to 1.75.1 — daanbouwman19/flight-planner-android0 reactions
- Aug 29, 2026Bump the dependencies group with 3 updates — Olsc/Android_ORB-SLAM2s0 reactions · 1 comment
- Aug 22, 2026chore(deps): bump filament from 1.71.5 to 1.75.0 — tianshantingyun/smart-mistake-book0 reactions
- Jun 13, 2026Add filament project — google/oss-fuzz0 reactions · 1 comment
- Mar 16, 2026deps(deps): bump filament_version from 1.68.2 to 1.70.0 — jtakumi/VtuberCamera0 reactions · 1 comment
- Dec 17, 2024Support cuda 12.2 — Open3DV/Open3D0 reactions
- Oct 7, 2024chore(deps): bump filament from `3ca9b9c` to `e9aeb93` — margelo/react-native-filament0 reactions
On Bluesky · 3
- Dec 12, 2024Android XR was unveiled today! You can download the preview SDK today and start using the Compose and Material Design APIs. I'm also… — @romainguy.dev131 likes and reposts · 2 replies
- Dec 3, 2025OpenGL at the moment; via filament (github.com/google/filam...) — @xenoprimate.bsky.social2 likes and reposts · 1 reply
- Aug 21, 2025I didn't write/work on the app, but I'm one of the authors of the 3D engine used by the app (github.com/google/filam...). I would have… — @romainguy.dev1 likes and repost
On Hacker News · 2
- Aug 4, 2018Physically Based Rendering Engine for Android, Windows, Linux and MacOS3 points
- Aug 5, 2018Google/filament: Filament is a physically based rendering engine1 point
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- docs/llms.txtllms.txt
- bindings-synchronizationSkill
- code-reviewSkill
- cpp-header-inclusionSkill
- filament-android-developmentSkill
- filament-build-cleanSkill
- filament-desktop-testingSkill
- header-self-containmentSkill
- preprocessor-guard-hygieneSkill
- verification-protocolsSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Immutability Invariant: Use LockGuard const as the default for all standard synchronized blocks to guarantee scope-bound read-only lock …
- Very specific: line 32
Condition Variables Overloads: Use UniqueLock (non-const) strictly when passing locks to condition variables (wait(lock)) or when explicit …
- Very specific: line 57
If the check is flat, completely inline the CV predicate as a standard while loop to bring the member variables directly into the parent …
- Very specific: line 69
Single-Threaded Parity: All thread safety annotations (UTILS_GUARDED_BY) are conditionally compiled out on single-threaded configurations.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
C++ Static Thread Safety & Synchronization Guidelines
Filament leverages Clang's static thread safety analysis to verify lock holding requirements at compile-time. All multi-threaded classes must use explicit capability annotations to guarantee race-free state access.
1. Selecting the Correct Lock Primitive
- Filament Primitives (
utils::Mutex&utils::Condition) — MANDATORY:- Rule: All engine, backend, and utility code under
filament/must useutils::Mutexandutils::Conditionexclusively. Do not usestd::mutexorstd::condition_variable. - Deadlock & Order Debugging:
utils::Mutextransparently integrates with Filament's compile-time lock debugging facility (FILAMENT_DEBUG_MUTEX/-u). When enabled, it maintains a global cycle dependency graph via BFS duringlock()andtry_lock(), immediately trapping lock-order inversions and self-deadlocks with exactCallStacktraces. Any locks defined viastd::mutexbypass this tracker entirely and remain invisible to deadlock diagnostics. - Memory & Cache Hygiene: On Android and Linux (
linuxutil::Mutex),utils::Mutexis only 4 bytes (a single atomic futex word) versus 40 bytes forstd::mutex. For structures allocated in large volumes or embedded in handles/fences, this 10x size reduction prevents struct bloat and maintains cache-line density. - Condition Variable Support:
utils::Condition(Condition::wait/wait_until) is explicitly templated (template <typename M>) to work seamlessly withUniqueLock<utils::Mutex>for producer-consumer queues and blocking wait loops. - Priority Inversion Reality: C++ standard
std::mutex(pthread_mutex_t) does not provide priority inheritance out of the box (PTHREAD_PRIO_NONE). Therefore,std::mutexoffers zero priority inversion protection overutils::Mutex.
- Rule: All engine, backend, and utility code under
2. Lock Guard & RAII Lifetime Conventions
- Immutability Invariant: Use
LockGuard constas the default for all standard synchronized blocks to guarantee scope-bound read-only lock scopes.// Correct utils::LockGuard const lock(mLock); - Condition Variables Overloads: Use
UniqueLock(non-const) strictly when passing locks to condition variables (wait(lock)) or when explicit.unlock()/.lock()boundaries are required for performance or deadlock prevention. - Lock Dependency: Any source file (
.cpp) that instantiatesLockGuardorUniqueLockmust explicitly include the matching utility header:#include <utils/Mutex.h>
3. Resolving Clang's Lambda Closure Limitations
Clang evaluates C++ anonymous closures (lambdas) as separate context boundaries. Because lambdas lack capability attributes, standard condition variable waits passing local predicates (e.g., using std::ranges::all_of) will trigger false-positive thread safety errors.
To resolve this, use one of the following approved patterns:
Pattern A: Inner Lambda Bypass (Recommended)
Decorate only the CV wait predicate lambda operator with UTILS_NO_THREAD_SAFETY_ANALYSIS to ignore nested boundaries while preserving outer compile-time checks:
UniqueLock lock(mQueueLock);
mQueueCondition.wait(lock, [this]() UTILS_NO_THREAD_SAFETY_ANALYSIS {
return mExitRequested ||
(!std::ranges::all_of(mQueues, [](auto&& q) { return q.empty(); }));
});Pattern B: Manual Loop Inlining
If the check is flat, completely inline the CV predicate as a standard while loop to bring the member variables directly into the parent function's locked scope:
UniqueLock lock(mLock);
while (mFreeSpace < requiredSize) {
mCondition.wait(lock);
}4. Dynamic Threading & Preprocessor Safety
- Single-Threaded Parity: All thread safety annotations (
UTILS_GUARDED_BY) are conditionally compiled out on single-threaded configurations. To prevent compile crashes whenFILAMENT_SINGLE_THREADEDis defined, standard annotations are gated byUTILS_HAS_THREADINGincompiler.h.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

