ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP.pm
Revision: 1.1
Committed: Thu Jul 30 08:38:50 2009 UTC (14 years, 9 months ago) by root
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# Content
1 =head1 NAME
2
3 AnyEvent::MP - multi-processing/message-passing framework
4
5 =head1 SYNOPSIS
6
7 use AnyEvent::MP;
8
9 =head1 DESCRIPTION
10
11 =cut
12
13 package AnyEvent::MP;
14
15 use common::sense;
16
17 use AE ();
18
19 our $VERSION = '0.0';
20
21 sub nonce($) {
22 my $nonce;
23
24 if (open my $fh, "</dev/urandom") {
25 sysread $fh, $nonce, $_[0];
26 } else {
27 # shit...
28 our $nonce_init;
29 unless ($nonce_init++) {
30 srand time ^ $$ ^ unpack "%L*", qx"ps -edalf" . qx"ipconfig /all";
31 }
32
33 $nonce = join "", map +(chr rand 256), 1 .. $_[0]
34 }
35
36 $nonce
37 }
38
39 our $DEFAULT_SECRET;
40
41 sub default_secret {
42 unless (defined $DEFAULT_SECRET) {
43 if (open my $fh, "<$ENV{HOME}/.aemp-secret") {
44 sysread $fh, $DEFAULT_SECRET, -s $fh;
45 } else {
46 $DEFAULT_SECRET = nonce 32;
47 }
48 }
49
50 $DEFAULT_SECRET
51 }
52
53 =head1 SEE ALSO
54
55 L<AnyEvent>.
56
57 =head1 AUTHOR
58
59 Marc Lehmann <schmorp@schmorp.de>
60 http://home.schmorp.de/
61
62 =cut
63
64 1
65