From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Musings on RxAda Date: Thu, 22 Oct 2015 14:33:47 +0200 Organization: cbb software GmbH Message-ID: References: <75f38e30-42ba-4e98-8f36-2218b5167209@googlegroups.com> <1wvo1b25eaa4o$.1y03vu1to6vux$.dlg@40tude.net> <18xpt5oxiz5nw$.klh515586pjp.dlg@40tude.net> <3a82a370-2175-4cf6-90e1-64fb19d794ff@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: TWQ9mg4k1m/sph/eQ+zHLA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:28034 Date: 2015-10-22T14:33:47+02:00 List-Id: On Thu, 22 Oct 2015 13:02:46 +0200, Alejandro R. Mosteo wrote: > Observable.fromClickEvents(SomeButton) > .onWorkerThread() -- To ensure we are not blocking the GUI thread > .count(during => one_second) -- This could be any costly operation > .onGuiThread() -- Switch back to GUI thread > .subscribe(count -> SomeTextLabel.setText(count)); This looks like a plain active object. On click you simply call its primitive operation Count, straight from the event handler. The implementation of Count calls a task-safe SetText which marshals back to the GUI messages loop. Basically, 2 source code lines. There is not much use in this anyway. In a real-life GUI it is far more complicated. When a detached asynchronous operation starts, you normally need to be able to indicate its progress, to be able to cancel it, have to deal with MVC mess etc. As an example see how GPS handles the "build" button clicks. A crude mechanism like Observable would not scale. > What I see interesting of this methodology is that it basically hides (in > theory, of course then you read about nightmare histories) the explicit > definition of tasks, It does not if you have to specify tasks. Active object does. > problems with race conditions and data integrity, I don't see why and how. It is too low level to judge. Especially integrity, because you seem ignore GUI elements bound to the detached execution. A typical problem is when SomeTextLabel gets killed while your thing keeps on counting... > The power of the setup comes with the huge number of predefined operators > that exist in the library. It's the closer to "chaining blocks" in something > like Simulink I've experienced in code. It is a poor analogy because Simulink is 100% synchronous. (We are using that to make real-time out of the simulated one. In a custom Simulink block we do "delay until", and here you are, all simulation gets blocked.) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de