Skip to content

Commit

Permalink
Baton and Futex: Add comments about async-signal-safety
Browse files Browse the repository at this point in the history
Summary: Add comments stating the expectations for Baton post and Futex wake native implementation to be async-signal-safe.

Reviewed By: ot, luciang

Differential Revision: D33461663

fbshipit-source-id: 2855427cc94f577b566b19203a4523f54a41d0aa
  • Loading branch information
magedm authored and facebook-github-bot committed Jan 7, 2022
1 parent e26fa87 commit e0204da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions folly/detail/Futex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ namespace {
////////////////////////////////////////////////////
// native implementation using the futex() syscall

// The native implementation of futex wake must be async-signal-safe.

#ifdef __linux__

/// Certain toolchains (like Android's) don't include the full futex API in
Expand Down Expand Up @@ -161,6 +163,8 @@ FutexResult nativeFutexWaitImpl(
///////////////////////////////////////////////////////
// compatibility implementation using standard C++ API

// This implementation may be non-async-signal-safe.

using Lot = ParkingLot<uint32_t>;
Lot parkingLot;

Expand Down
5 changes: 5 additions & 0 deletions folly/synchronization/Baton.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ namespace folly {
/// DeterministicSchedule. By having a much more restrictive
/// lifecycle we can also add a bunch of assertions that can help to
/// catch race conditions ahead of time.
///
/// Baton post with MayBlock == false is async-signal-safe.
/// When MayBlock == true, Baton post is async-signal-safe if
/// Futex wake is so.

template <bool MayBlock = true, template <typename> class Atom = std::atomic>
class Baton {
public:
Expand Down

0 comments on commit e0204da

Please sign in to comment.