ZeroMQ::Context(3pm)

ZeroMQ::Context3pm

A 0mq context object

Usage

  use ZeroMQ qw/:all/;
  
  my $cxt = ZeroMQ::Context->new;
  my $sock = ZeroMQ::Socket->new($cxt, ZMQ_REP);

Overview

Before opening any 0MQ Sockets, the caller must initialise a 0MQ context.

Methods

new($nthreads)

Creates a new "ZeroMQ::Context".

Optional arguments: The number of io threads to use. Defaults to 1.

term()

Terminates the current context. You *RARELY* need to call this yourself, so don't do it unless you know what you're doing.

socket($type)

Short hand for ZeroMQ::Socket::new.

ctxt

Return the underlying ZeroMQ::Raw::Context object

Caveats

While in principle, "ZeroMQ::Context" objects are thread-safe, they are currently not cloned when a new Perl ithread is spawned. The variables in the new thread that contained the context in the parent thread will be a scalar reference to "undef" in the new thread. This could be fixed with better control over the destructor calls.