April 2024 - This site, and Kamaelia are being updated. There is significant work needed, and PRs are welcome.

Axon.ThreadedComponent.threadedadaptivecommscomponent

For examples and more explanations, see the module level docs.


class threadedadaptivecommscomponent(threadedcomponent, Axon.AdaptiveCommsComponent._AdaptiveCommsable)

threadedadaptivecommscomponent([queuelengths]) -> new threadedadaptivecommscomponent

Base class for a version of an Axon adaptivecommscomponent that runs main() in a separate thread (meaning it can, for example, block).

Subclass to make your own.

Internal queues buffer data between the thread and the Axon inboxes and outboxes of the component. Set the default queue length at initialisation (default=1000).

Like an adaptivecommscomponent, inboxes and outboxes can be added and deleted at runtime.

A simple example:

class IncrementByN(Axon.ThreadedComponent.threadedcomponent):

    Inboxes = { "inbox" : "Send numbers here",
                "control" : "NOT USED",
              }
    Outboxes = { "outbox" : "Incremented numbers come out here",
                "signal" : "NOT USED",
               }

    def __init__(self, N):
        super(IncrementByN,self).__init__()
        self.n = N

    def main(self):
        while 1:
            while self.dataReady("inbox"):
                value = self.recv("inbox")
                value = value + self.n
                self.send(value,"outbox")

            if not self.anyReady():
                self.pause()

Methods defined here

__init__(self, *argL, **argD)

_unsafe_addInbox(self, *args)

Internal thread-unsafe code for adding an inbox.

_unsafe_addOutbox(self, *args)

_unsafe_deleteInbox(self, name)

_unsafe_deleteOutbox(self, name)

addInbox(self, *args)

Allocates a new inbox with name based on the name provided. If a box with the suggested name already exists then a variant is used instead.

Returns the name of the inbox added.

addOutbox(self, *args)

Allocates a new outbox with name based on the name provided. If a box with the suggested name already exists then a variant is used instead.

Returns the name of the outbox added.

deleteInbox(self, name)

Deletes the named inbox. Any messages in it are lost.

Try to ensure any linkages to involving this outbox have been destroyed - not just ones created by this component, but by others too! Behaviour is undefined if this is not the case, and should be avoided.

deleteOutbox(self, name)

Deletes the named outbox.

Try to ensure any linkages to involving this outbox have been destroyed - not just ones created by this component, but by others too! Behaviour is undefined if this is not the case, and should be avoided.

Methods inherited from Axon.ThreadedComponent.threadedcomponent :

Methods inherited from Axon.Component.component :

Methods inherited from Axon.Microprocess.microprocess :

Methods inherited from Axon.AdaptiveCommsComponent._AdaptiveCommsable :

Feedback

Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!

Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.

-- Automatic documentation generator, 09 Dec 2009 at 04:00:25 UTC/GMT