[haiku-3rdparty-dev] Re: Replicants connection to BApplication

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Thu, 04 Feb 2010 10:20:01 +0100

On 2010-02-04 at 01:20:27 [+0100], Sevcsik András <sevcsik@xxxxxxxxx> wrote:
> 
> Sorry to bother you again. In my app (Paste-O-Matic, if you remember
> :)), I have a window, with an icon in it. All time-consuming
> operations (http operations in my case) are done in the BApplication
> thread, to keep window responsive. be_app sends messages to the
> window, to update status.
> 
> My problem is, that I want to make this icon a replicant, but I don't
> see how it will communicate with my be_app. Replicants are BViews,
> thus they don't have a message loop. How can they receive messages
> then? And if they could, how can I access them from my be_app?

Others have already answered your questions. I just want to add the 
suggestion to not do networking in the application thread. Most of the time 
the app thread is just sitting there waiting for messages. So most 
developers also do things in it, that one certainly wouldn't want to do in 
a window thread, including e.g. short I/O. That's usually OK, since the 
thread generally doesn't need to be particularly responsive. Networking, 
however, is quite a different thing, since at worst it is orders of 
magnitude slower and has huge timeouts. When the network connection hangs 
for some reason, your application won't be able to quit until the timeout 
occurs. That is unless you can explicitly terminate the network connection 
(e.g. by shutting down/closing the socket), but that's obviously not 
possible, if the quit request came from the outside (e.g. initiated by the 
user wanting to shut down the system) and thus goes through the 
unresponsive app looper.

A replicant should never do anything time-consuming in the app thread (or 
in the window thread for that matter).

CU, Ingo

Other related posts: