Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: How do I get a unique Perl Interpreter ID?

by ikegami (Pope)
on Dec 01, 2011 at 04:40 UTC ( #940999=note: print w/replies, xml ) Need Help??

in reply to How do I get a unique Perl Interpreter ID?

use strict; use warnings; use feature qw( say ); use Inline C => <<'__EOI__'; IV get_interpreter_id() { return (IV)PERL_GET_THX; } __EOI__ say get_interpreter_id();
>perl 3092452


The XS is simply

#include "EXTERN.h" #include "perl.h" #include "XSUB.h" MODULE = Foo PACKAGE = Foo IV get_interpreter_id() CODE: RETVAL = (IV)PERL_GET_THX; OUTPUT: RETVAL

Replies are listed 'Best First'.
Re^2: How do I get a unique Perl Interpreter ID?
by wrog (Friar) on Dec 02, 2011 at 21:42 UTC
    okay, this, with some minor changes, now exists as Thread::IID:
    • (UV) instead of (IV).
    • left off the 'get_'
    • returns PERL_GET_THX>>11 because PerlInterpreter structures are Just Huge (2800 bytes in my world) and this reduces the returned numbers somewhat.
    Enjoy. And thanks.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://940999]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2016-10-22 06:06 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (292 votes). Check out past polls.