I would like to learn more about how you can control where each Scala works. I found myself in a few specific cases: high reactivity is required, a significant part of the code is critical, and, worst of all, I'm on Android. With this in mind, my main goal is to make the code as clear and understandable as possible.
What I ideally would like to achieve (some of those that sound unreasonably / completely stupid, first read the discussion below)
- I would like to be able to reply to some messages in a specific, always the same, arbitrary stream, but to me no need to block it to wait for messages.
“I would like most of my processing to be done in a workflow pool, ideally automatic resizing as Scala support, ensuring that this processing will never be performed on an arbitrary thread above.”
These requirements are necessitated by Android: the Android platform uses a special thread to touch the user interface, and if you touch any user interface object from another thread, you get an exception. Thus, it applies some kind of thread / lock model, which is exactly what I'm trying to work with. But anyway, the way it is: I have to ensure that part of my processing, namely, that deals with user interface objects, works on this thread, and the other does not, because the view annoyingly says that I should do it. An unfortunate side effect of this is, as long as this thread processes my code, the user interface stops updating, and my application stops being responsive. So I need to make surethat this thread is not randomly selected for long code that I could use in some reactions {}, and ideally, it never processes what can be done by another thread.
Android Handle, - - Runnable . , . Runnable - , , - - , - onUIThread {/* */}
... Runnable() {def run() {}}. , , onUIThread, - . , , , GC Android, 150 , , .
, :
- - , , {} ? /* , , , , */
- - , {}?
- , , , ?