[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-dbus
Subject:    Re: dbus questions
From:       Gordon Tyler <gordon () doxxx ! net>
Date:       2003-12-09 16:23:58
Message-ID: 3FD5F71E.7080405 () doxxx ! net
[Download RAW message or body]

David Zeuthen wrote:
> 2. Message dependencies
> 
> I have an situation where I know that I will receive several messages, 
> but one of
> the early messages need to wait for a later message to have been processed,
> before the early message itself can be processed (possibly with some 
> timeout).
> 
> How is this easiest achieved? I suppose the only answer is go 
> multithreaded (even
> though I really want to avoid this); Is D-BUS designed to do this? I 
> can't seem to
> find anything useful about this in the docs..

I get the impression that this is not within D-BUS' domain. It's an 
application-level requirement which you could probably achieve without 
multi-threading by using a queue-like system:

1. You receive message A but you determine that it requires message B to 
be processed first. You push it onto the queue, making a note of its 
dependencies and continue listening for messages.
2. You receive message B but you determine that it requires message C to 
be processed first. You also push it onto the queue and continue 
listening for messages.
3. You receive message C that has no dependencies. You process it:
    a. You search through the queue in most-recent-to-oldest order, 
looking for a message that depends on the message being processed, 
finding message B.
    b. Having found message B, you make a note in the message that it's 
message C dependency has been satisified.
    c. Since message B has had all its dependencies satisfied, you 
process it as above.
    d. Continue searching for a message which depends on message C.

Or something along those lines. Some provision would have to be made to 
keep track of situations like message C arriving first.

Ciao,
Gordon


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic