[haiku-development] Re: A BMessage w/o a BApplication?

  • From: fano il primo <fanoilprimo@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 29 Jan 2012 20:17:02 +0100

On Sun, Jan 29, 2012 at 7:10 PM, Adrien Destugues <
pulkomandy@xxxxxxxxxxxxxxxxx> wrote:

> Le 29/01/2012 18:55, fano il primo a écrit :
>
>> Ahh I _DO love_ this API!
>>
>>
>> Let's see if I've understood correctly, sirs:
>>
>> This is the MessageReceived of my main application (that's the class that
>> extended beApplication, a special case of BLooper as it is not a thread but
>> it's the main() that continues as an unique thread of execution, correct?):
>> |MessageReceived|(BMessage*|  msg) {
>> switch(msg->what) {
>> ||case btn1:
>>     NetHandler->||||PostMessage|(**new|BMessage|(|DO_SOMETHING|),
>> NULL);|||
>>
>>
>> }|||
>>
>> And this my  MessageReceived() of my looper class that is another thread
>> in the same memory space of my beApp:
>> |MessageReceived|(BMessage*|  msg) {
>>
>>
>> switch(msg->what) {
>> ||case||DO_SOMETHIN||:
>>     /* well.. DO send something in the Network, right?||
>> }|||
>> So this is the right way to do a BeOS / Haiku application, right? If I've
>>  to do something with slow resource I have to use a thread or better a
>> BLooper... I love this! It's so... automatic and simple... in Windows or
>> worst in Linux you're very tempted to be lazy and use select() in your
>> MAIN()... and your GUI blocks!
>>
>> Here, simply, I've BLooper already done... simply I'd read the Docs (and
>> surprising they are... and are clear, too!) and I'm ready to go...
>>
>>  Looks fine.
>
>  Maybe the code in which the Message mechanics was re-implemented was in
>> Kernel code?
>> I'd suppose Kernel cannot use BLooper code... or it could?
>>
> Of course you need a BApplication for this to work. In the kernel or
> app_server things get to lower level code and you have to use ports and
> shared areas. The BMessage system is using the same, but hides it from you
> and handles most of the synchronisation problems between all the threads.
>
> --
> Adrien.
>

Thanks and... "the more I know"  :-)))

Not I've to say all is clear... so in Kernel is now obvius cannot be
done... maybe for code clean we can do a library usable from the kernel and
NOT for userland apps... as we've Blooper.

Ahh sad I've to work with Linux everyday... well I hope in 10 years for
now... a man can dream, right?

Other related posts: