C# FBP Features
- Dropping a packet is now done by a method of class Component (as opposed to a method of class Packet), e.g.:
- We are adding a "long wait" state to components, specifying a timeout value in seconds. This is coded as follows:
double _timeout = 2; // 2 secs
// activity taking time goes here
- Typically, the timeout value is given a default value in the code, and overridden (if desired) by an IIP.
- While the component in question is executing the activity taking time, its state will be set to "long wait". If one or more components are in "long wait" state while all other components are suspended or not started, this situation is not treated as a deadlock. However, if one of the components exceeds its timeout value, an error will be reported (Complain).
- I have become persuaded by DavidBennett that a components' responsibility for an IP is discharged once it issues a Send - see UndeliveredMail. This suggests that Send should not return a "success/fail" indicator, but should simply crash the program (FlowError.Complain) if a data packet cannot be delivered - either because the receiving input port is closed, or no connection was specified. This means that the network designer should connect any output ports sending unneeded data to a Discard or Log component.
- This assumes that the component names have been associated with a type in an earlier statement of the form
- If one of the ports involved is an array port, the port array name and index can be entered as
- where "index" is an absolute number - either in a "connect" or an "initialize" statement.
- Input and output port names will be coded on components using attribute notation. This is metadata that can be used to do analysis of networks without having to actually execute the components involved. Here is an example of the attributes for the "Collate" component:
[InPort("IN", arrayPort = true)]
public class Collate : Component
- Input ports do not necessarily have to be connected, even though attributes are specified for them; output ports, however, must be.
- Attribute notation is also used to specify the MustRun attribute, as follows:
- Also for setting the component priority, as follows:
- - the default priority for components is ThreadPriority.Normal. This attribute will be supported in the C#FBP-2.2 version (to be released in early April, 2008).
- The input ports to which IIPs are connected should be closed by the component code after the receive has been done - this ensures that, if fed by an upstream component rather than an IIP, only one IP can be sent successfully. Once the port is closed, an additional send will cause the sending component to abort. When making a component available for general use, all IIP ports should be tested using a data stream connection, as well as an IIP.
- Unlike the 1.5.3 and earlier versions of JavaFBP, an IIP will only be received once per invocation - additional receives just return null. This change will also be implemented in the next release of JavaFBP.
- ... and of course the services all start with upper case letters...