Action icon indicating copy to clipboard operation
Action copied to clipboard

`CocoaAction` thread safety

Open mosamer opened this issue 8 years ago • 4 comments

While there is no guarantees for thread-safety on Action. CocoaAction exposed public API should guarantee delivering events on main thread to ensure safe binding to UI.

mosamer avatar Nov 02 '17 19:11 mosamer

IMO, #40 might be taken into consideration while discussing this.

mosamer avatar Nov 02 '17 19:11 mosamer

Good point here I would go with something like this MainScheduler.ensureExecutingOnScheduler() and then throw a fatalError if not.

bobgodwinx avatar Nov 03 '17 11:11 bobgodwinx

I am not sure how MainSchdulre.ensureExecutingOnScheduler() can be used here

mosamer avatar Nov 07 '17 09:11 mosamer

MainScheduler.ensureExecutingOnScheduler() is widely used mainly to make sure that subsequent lines of code that follows will be executed on the main queue for example Drivers are executed on the main queue like this MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage). So Action should not be that different. An alternative would be to start asking the user to provide us a Scheduler where to run the code. But this will be an overkill IMHO

bobgodwinx avatar Nov 07 '17 10:11 bobgodwinx