Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 (Monk) 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 scrutinizing the Monastery: (3)
As of 2014-09-20 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (164 votes), past polls