ZMQ::Declare::Device - A ZMQ::Declare Device object
use ZMQ::Declare; # See synopsis for ZMQ::Declare
Instances of this class represent a single 0MQ device. With less 0MQ jargon, that means they represent a single component of your network of things that interact using 0MQ sockets.
You typically obtain these objects by calling the device method on a ZMQ::Declare::Application object. It is important to note that a ZMQ::Declare::Device object contains no runtime 0MQ components like sockets or 0MQ contexts and maintains no network connections. This is to say that you can create and use ZMQ::Declare::Device in an abstract, offline way.
device
ZMQ::Declare::Device
Shit gets real once you call the run() or make_runtime methods on a ZMQ::Declare::Device: Those methods will (the former implicitly, the latter explicitly) construct a ZMQ::Declare::Device::Runtime object, create a threading context, create sockets, and make connections.
run()
make_runtime
ZMQ::Declare::Device::Runtime
The ZMQ::Declare::Device::Runtime object will then hold the actual references to the underlying 0MQ objects.
This clear split should make it easy for users to know when they are handling live or abstract devices.
These are accessible with normal mutator methods.
The name of the device. This is required to be unique in a ZDCF context and cannot be context.
The type of the device that's represented by the object. Types starting with z are reserved for core 0MQ devices.
The device type is optional as of ZDCF spec version 1.0.
Read-only.
The code-reference that is to be invoked by the run() method of the object. This needs to be set by the user before calling run(). The code-reference will be called by run() with a ZMQ::Declare::Device::Runtime object as first argument.
A reference to the underlying ZMQ::Declare::Application object.
ZMQ::Declare::Application
Constructor taking named arguments (see properties above). Typically, you should obtain your ZMQ::Declare::Device objects by calling device($devicename) on a ZMQ::Declare::Application object instead of using new().
device($devicename)
new()
Requires that an implementation has been set previously (see the implementation property above).
implementation
Accepts named arguments and currently only accepts the nforks option which, if it is larger or equal to two, will fork off nforks child processes before doing any further setup. The parent will return from run() after all children have been reaped. Each child will perform the actions described below.
nforks
Calls make_runtime to obtain a new ZMQ::Declare::Device::Runtime.
Then, it invokes the CODE reference that is stored in the implementation property and passes the ZMQ::Declare::Device::Runtime object as first argument.
Creates a ZMQ::Declare::Device::Runtime object to hold a 0MQ threading context and all 0MQ socket objects. It sets up the context, creates the sockets, configures the sockets, binds the sockets to bind-endpoints, then finally connects the sockets to connect-endpoints.
Returns the Runtime object. Once that object goes out of scope, all connections will be disconnected.
ZeroMQ
ZMQ::Declare, ZMQ::Declare::Device::Runtime, ZMQ::Declare::Application
Steffen Mueller <smueller@cpan.org>
Copyright (C) 2011,2012 by Steffen Mueller
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available.
To install ZMQ::Declare, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ZMQ::Declare
CPAN shell
perl -MCPAN -e shell install ZMQ::Declare
For more information on module installation, please visit the detailed CPAN module installation guide.