Skip to content

Conversation

@unbalancedparentheses
Copy link
Contributor

Summary

  • Add HasPid implementation to GenServerHandle
  • Add link/unlink, monitor/demonitor methods
  • Add trap_exit support
  • Add register/unregister for registry integration
  • Add handle_info callback for system messages
  • Add teardown callback
  • Add stop() method
  • Add start_linked() and start_monitored() helpers
  • Add InitResult and InfoResponse types
  • Register with process_table on start
  • Add Sync bound to message types for consistency with tasks
  • Update timer_tests to use new InitResult

Threads GenServer now has full feature parity with tasks version.

Files Changed

  • concurrency/src/threads/gen_server.rs (+298 lines)
  • concurrency/src/threads/mod.rs (+7 lines)
  • concurrency/src/threads/timer_tests.rs (+8 lines)

Dependencies

⚠️ Depends on PR #68, #69, #70, #71 - merge those first

Merge Order

PR #68 → PR #69 → PR #70 → PR #71 → PR #X (this) → PR #X

🤖 Generated with Claude Code

unbalancedparentheses added 5 commits January 8, 2026 14:09
- Add Pid struct with unique process identifiers (AtomicU64)
- Add HasPid trait for types that have a process ID
- Add ExitReason enum (Normal, Shutdown, Error, Killed)
- Add MonitorRef for tracking monitors
- Add SystemMessage enum (Down, Exit, Timeout)

These are the foundational types for OTP-style process management.
- Add ProcessTable with global process tracking
- Implement bidirectional linking (link/unlink)
- Implement unidirectional monitoring (monitor/demonitor)
- Add trap_exit support for catching linked process exits
- Add SystemMessageSender trait for delivering DOWN/EXIT messages
- Handle exit propagation to linked processes

The process table is the central registry for all running processes
and manages the relationships between them.
- Add global Registry for name -> Pid mapping
- Implement register/unregister functions
- Add whereis for name lookup
- Add name_of for reverse lookup (Pid -> name)
- Prevent duplicate names and multiple names per process
- Add comprehensive tests with mutex for isolation

Enables Erlang-style named processes for easier discovery.
- Add HasPid implementation to GenServerHandle
- Add link/unlink methods for bidirectional process linking
- Add monitor/demonitor for unidirectional monitoring
- Add trap_exit/is_trapping_exit for exit handling
- Add register/unregister for registry integration
- Add handle_info callback for system messages (DOWN, EXIT, Timeout)
- Add teardown callback for cleanup on stop
- Add stop() convenience method
- Add start_linked() and start_monitored() helpers
- Add InitResult enum for init success/failure handling
- Register/unregister with process_table on start/stop
- Use futures::select_biased for message prioritization
- Fix typos in documentation

GenServer now fully integrates with the OTP-style process model.
- Add HasPid implementation to GenServerHandle
- Add link/unlink, monitor/demonitor methods
- Add trap_exit support
- Add register/unregister for registry integration
- Add handle_info callback for system messages
- Add teardown callback
- Add stop() method
- Add start_linked() and start_monitored() helpers
- Add InitResult and InfoResponse types
- Register with process_table on start
- Add Sync bound to message types for consistency
- Update timer_tests to use new InitResult

Threads GenServer now has full parity with tasks version.
@unbalancedparentheses unbalancedparentheses changed the title feat: bring threads GenServer to feature parity with tasks [5/6] feat: bring threads GenServer to feature parity with tasks Jan 8, 2026
@unbalancedparentheses
Copy link
Contributor Author

Closing this PR as it's superseded by PR #74 (Backend enum). The Backend enum unification already brings threads GenServer to parity by providing a single implementation that can run on any backend (Async, Blocking, Thread).

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