comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Musings on RxAda
Date: Thu, 22 Oct 2015 14:33:47 +0200
Date: 2015-10-22T14:33:47+02:00	[thread overview]
Message-ID: <ysi55ohsga9g$.1gzafj1qtbdfl$.dlg@40tude.net> (raw)
In-Reply-To: n0afkm$ssa$1@dont-email.me

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


  reply	other threads:[~2015-10-22 12:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14 14:30 Musings on RxAda Alejandro R.  Mosteo
2015-10-15 14:40 ` brbarkstrom
2015-10-21 11:45 ` Hadrien Grasland
2015-10-21 12:12 ` Hadrien Grasland
2015-10-21 13:35   ` Dmitry A. Kazakov
2015-10-21 16:18     ` Hadrien Grasland
2015-10-21 16:47       ` Dmitry A. Kazakov
2015-10-21 19:09         ` Hadrien Grasland
2015-10-21 19:35           ` Dmitry A. Kazakov
2015-10-21 21:04             ` Hadrien Grasland
2015-10-22 11:02               ` Alejandro R.  Mosteo
2015-10-22 12:33                 ` Dmitry A. Kazakov [this message]
2015-10-22 16:41                   ` Alejandro R.  Mosteo
2015-11-19 13:14 ` Jacob Sparre Andersen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox