hpi-swa-lab / squeak-spelling-services

MIT License
0 stars 0 forks source link

Make `IspellSpellingInterface` thread-safe #4

Open LinqLover opened 3 years ago

LinqLover commented 3 years ago

At the moment, IspellSpellingInterface is not thread-safe, so with some bad luck, two concurring senders could create and reset the temporary file at the same. This should be fixed either by using a mutex (blocking and boring solution) or process-specific temporary file names (elegant solution).

marceltaeumel commented 3 years ago

If the primary use case is UI, then a mutex would be fine. Or take a look at Shout's background styling in SHTextStyler >> #styleInBackgroundProcess:, which does not need a mutex at all, but captures state in individual instances of SHTextStylerST80. Meaning, a text morph having its own spell checker could work.

"Process-specific temp files" reads like you want to push the global use case of spell checkers further. That's maybe not a good idea. Maybe store those names in the instance of SpellingInterface (if not already done so) and document it in its class comment that it is not a good idea to share those instances between processes, which is best practice anyway.