Skip to content

Naive C++23 implementation for the airlock problem#1

Open
AbsintheScripting wants to merge 1 commit into
mainfrom
solution-in-cpp
Open

Naive C++23 implementation for the airlock problem#1
AbsintheScripting wants to merge 1 commit into
mainfrom
solution-in-cpp

Conversation

@AbsintheScripting
Copy link
Copy Markdown
Owner

Using a mutex on the airlock for synchronization.

  • Astronauts are printing to the console what they are doing
  • Work is simulated with thread-sleeps
  • Unit tests using GTest validate correctness

Example output:

[Astro-Outside] Starting mission to move from outside to inside.
[Astro-Inside] Starting mission to move from inside to outside.
[Astro-Inside] Trying to open the inside door...
[Astro-Outside] Trying to open the outside door...
[Astro-Inside] Could not open inside door.
[Astro-Inside] Trying to cycle airlock from inside...
[Astro-Inside] Could not cycle airlock.
[Astro-Outside] Opened outside door.
[Astro-Outside] Moving to chamber...
[Astro-Inside] Trying to open the inside door...
[Astro-Outside] Reached chamber.
[Astro-Outside] Closing outside door...
[Astro-Inside] Could not open inside door.
[Astro-Inside] Trying to cycle airlock from inside...
[Astro-Inside] Could not cycle airlock.
[Astro-Outside] Closed the outside door.
[Astro-Outside] Trying to cycle airlock from chamber...
[AirLock] Chamber is cycling from empty to pressurized state.
[Astro-Inside] Trying to open the inside door...
[Astro-Inside] Could not open inside door.
[Astro-Inside] Trying to cycle airlock from inside...
[Astro-Inside] Could not cycle airlock.
[AirLock] Chamber cycled to pressurized state.
[Astro-Outside] Cycled airlock. Safe to exit now.
[Astro-Outside] Trying to open the inside door...
[Astro-Inside] Trying to open the inside door...
[Astro-Outside] Opened inside door.
[Astro-Outside] Moving to inside...
[Astro-Inside] Someone else opened the door.
[Astro-Inside] Moving to chamber...
[Astro-Outside] Reached inside.
[Astro-Outside] Closing inside door...
[Astro-Inside] Reached chamber.
[Astro-Inside] Closing inside door...
[Astro-Outside] Closed the inside door.
[Astro-Outside] Reached destination inside.
[Astro-Inside] Someone else closed the door.
[Astro-Inside] Trying to cycle airlock from chamber...
[AirLock] Chamber is cycling from pressurized to empty state.
[AirLock] Chamber cycled to empty state.
[Astro-Inside] Cycled airlock. Safe to exit now.
[Astro-Inside] Trying to open the outside door...
[Astro-Inside] Opened outside door.
[Astro-Inside] Moving to outside...
[Astro-Inside] Reached outside.
[Astro-Inside] Closing outside door...
[Astro-Inside] Closed the outside door.
[Astro-Inside] Reached destination outside.
All astronauts have finished their maneuvers.

…ization.

- Astronauts are printing to the console what they are doing
- Work is simulated with thread-sleeps
- Unit tests using GTest validate correctness
@AbsintheScripting AbsintheScripting self-assigned this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant