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

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 a.pl 3092452

(Also perl -MInline=FORCE,NOISY,NOCLEAN a.pl)

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


Comment on Re: How do I get a unique Perl Interpreter ID?
Select or Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2015-07-04 13:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls