You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add thread safety to Bayes and LSI classifiers (#86)
* feat: add thread safety to Bayes and LSI classifiers
Both classifiers now use Mutex_m for thread-safe operations. Concurrent
train() and classify() calls no longer corrupt internal state.
Key changes:
- Include Mutex_m in both Bayes and LSI classes
- Wrap all public methods accessing shared state in synchronize blocks
- Add unlocked private variants for internal calls to avoid deadlock
- Implement marshal_dump/marshal_load to handle serialization (Mutex
cannot be marshaled)
The pattern used avoids deadlock by having public methods delegate to
unlocked private methods when the lock is already held.
Closes#66
* fix: add Mutex_m RBS type stubs for validation
The rbs-inline tool generates 'include Mutex_m' in the type
signatures for Bayes and LSI classes, but RBS validation fails
because it cannot find the Mutex_m type definition.
Add vendor type stubs with the core mutex methods and their
standard aliases (synchronize, lock, unlock, etc.) to satisfy
both RBS validation and Steep type checking.
* fix: resolve RuboCop and Steep type check issues
Extract GSL and native matrix vector assignment into helper methods
to reduce build_index method length below the 25-line threshold.
Use anonymous block forwarding (&) per Ruby 3.1+ style preferences
for the unlocked proxy methods.
0 commit comments