boostorg / boostorg/interprocess
Semaphore use in signals
- Lenguaje dominante
- C++
- Estrellas
- 185
- Forks
- 131
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I am using interprocess' semaphore in conjunction with timed_wait, and I need to be able to handle SIGINT to terminate the waiting early. Looking into the implementation, I can see that I am getting the spin semaphore internally, which suggests to me that `post()`ing it from the signal handler is safe, since it is effectively just an atomic increment.
This would likely not hold in other types of internal implementations of the semaphore. For example, while POSIX implementation seems to be fine in the first line (it just uses `sem_post`), it can later throw an exception.
This leads me to two thoughts:
1. Can we have a variant of the POSIX post() that would not throw an exception?
2. Can we add compile-time introspection for signal safety of the chosen semaphore implementation? So that one can do something like `static_assert(boost::interprocess::interprocess_semaphore::signal_safe_post)`.
I am happy to contribute such improvements if there's a consensus.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
No se nombra ningún archivo ni prueba. Empieza siguiendo las implementaciones de semáforos utilizadas por interprocess_semaphore, especialmente las rutas spin y POSIX, y cómo timed_wait interactúa con SIGINT. Se considera terminado cuando el proyecto tenga un diseño establecido para un POSIX post que no lance excepciones y para información sobre la seguridad de señales disponible en tiempo de compilación.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- cpp
- Área
- operating-systems
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100