One-shot sending dataOneShot and TriggeredOneShot send a single specified item to their "outbox" outbox and immediately terminate. TriggeredOneShot waits first for anything to arrive at its "inbox" inbox, whereas OneShot acts as soon as it is activated. Example UsageA way to create a component that writes data to a given filename, based on (filename,data) messages sent to its "next" inbox: Carousel( lambda filename, data : Pipeline( OneShot(data), SimpleFileWriter(filename), ), ) A graphline that opens a TCP connection to myserver.com port 1500, and sends an a one off message: Pipeline( OneShot("data to send to server"), TCPClient("myserver.com", 1500), ).run() Shutting down a connection to myserver.com port 1500 as soon as a reply is received from the server: Graphline( NET = TCPClient("myserver.com", 1500), SPLIT = TwoWaySplitter(), STOP = TriggeredOneShot(producerFinished()), linkages = { ("", "inbox" ) : ("NET", "inbox"), ("NET", "outbox") : ("SPLIT", "inbox"), ("SPLIT", "outbox") : ("", "outbox"), ("SPLIT", "outbox2") : ("STOP", "inbox"), ("STOP", "outbox") : ("NET", "control"), ("", "control") : ("NET", "control"), ("NET", "signal") : ("SPLIT", "control"), ("SPLIT", "signal") : ("", "signal"), ("SPLIT", "signal2"),: ("STOP", "control"), }, ) OneShot BehaviourAt initialisation, specify the message to be sent by OneShot. As soon as OneShot is activated, the specified message is sent out of the "outbox" outbox. A producerFinished message is also sent out of the "signal" outbox. The component then immediately terminates. TriggeredOneShot BehaviourAt initialisation, specify the message to be sent by TriggeredOneShot. Send anything to the "inbox" inbox and TriggeredOneShot will immediately send the specified message out of the "outbox" outbox. A producerFinished message is also sent out of the "signal" outbox. The component then immediately terminates. If a producerFinished or shutdownMicroprocess message is received on the "control" inbox. It is immediately sent on out of the "signal" outbox and the component then immediately terminates. Kamaelia.Util.OneShot.OneShotclass OneShot(Axon.Component.component)OneShot(msg) -> new OneShot component. Immediately sends the specified message and terminates. Keyword arguments: - msg -- the message to send out Inboxes
Outboxes
Methods defined hereWarning! You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers. __init__(self[, msg])x.__init__(...) initializes x; see x.__class__.__doc__ for signature main(self)Main loop Kamaelia.Util.OneShot.TriggeredOneShotclass TriggeredOneShot(Axon.Component.component)OneShot(msg) -> new OneShot component. Waits for anything to arrive at its "inbox" inbox, then immediately sends the specified message and terminates. Keyword arguments: - msg -- the message to send out Inboxes
Outboxes
Methods defined hereWarning! You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers. __init__(self[, msg])x.__init__(...) initializes x; see x.__class__.__doc__ for signature main(self)Main loop FeedbackGot 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, 05 Jun 2009 at 03:01:38 UTC/GMT |
Kamaelia
is an open source project originated from and guided by BBC
Research. For more information browse the site or get in
contact.
This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)
(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved.