Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2018-06-22 02:00 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (120 votes). Check out past polls.