This file is indexed.

/usr/share/perl5/POE/API/Peek.pm is in libpoe-api-peek-perl 2.2000-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
package POE::API::Peek;
{
  $POE::API::Peek::VERSION = '2.20';
}
# ABSTRACT: Peek into the internals of a running POE environment


use 5.006001;
use warnings;
use strict;


BEGIN {
	use POE;
	my $ver = $POE::VERSION;
	$ver =~ s/_.+$//;
	if($ver < '1.300') {
		die(__PACKAGE__." is only certified for POE version 1.300 and up and you are running POE version " . $ver . ". Check CPAN for an appropriate version of ".__PACKAGE__.".");
	}
}

use POE;
use Devel::Size qw(total_size);
$Devel::Size::warn = 0;

use Carp;
our @CARP_NOT = qw(__PACKAGE__);

# new {{{


sub new {
	my $class = shift;
	my $self = {
		broken_event_queue_bitch => 0,
	};
	return bless $self, $class;
}

# }}}

# id() {{{


sub id { return $poe_kernel->ID }

# }}}

# Kernel fun {{{


# is_kernel_running {{{


sub is_kernel_running {
	my $kr_run_warning = ${ $poe_kernel->[ POE::Kernel::KR_RUN() ] };

	if($kr_run_warning |= POE::Kernel::KR_RUN_CALLED()) {
		return 1;
	} else {
		return 0;
	}
}

#}}}

# active_event {{{


sub active_event {
	return ${ $poe_kernel->[ POE::Kernel::KR_ACTIVE_EVENT() ] };
}

#}}}

# kernel_memory_size {{{


sub kernel_memory_size {
	return total_size($poe_kernel);
}
# }}}

# event_list {{{


sub event_list {
	my $self = shift;

	my %events;
	foreach my $session_ref (keys %{ $poe_kernel->[ &POE::Kernel::KR_SESSIONS() ] }) {
		my $session = $poe_kernel->[ &POE::Kernel::KR_SESSIONS() ]->{ $session_ref }->[ &POE::Kernel::SS_SESSION() ];
		next if $session->isa('POE::Kernel');
		my $id = $session->ID;

		my @events = sort keys %{ $session->[ &POE::Session::SE_STATES() ] };

		$events{ $id } = \@events;
	}

	return \%events;
}
# }}}

# which_loop {{{


sub which_loop {
	return POE::Kernel::poe_kernel_loop();
}

#}}}


# }}}

# Session fun {{{


# current_session {{{


# the value of KR_ACTIVE_SESSION is a ref to a scalar. so we deref it before
# handing it to the user.

sub current_session { return ${ $poe_kernel->[POE::Kernel::KR_ACTIVE_SESSION] } }

# }}}

# get_session_children {{{


sub get_session_children {
	my $self = shift;
	my $session = shift || $self->current_session();
	my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_ses_get_children($sid);
}
# }}}

# is_session_child {{{


sub is_session_child {
	my $self = shift;
	my $parent = shift or return undef;
	my $psid = ref $parent ? $parent->ID : $parent;
	my $session = shift || $self->current_session();
	my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_ses_is_child($psid, $sid);
}
# }}}

# get_session_parent {{{


sub get_session_parent {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_ses_get_parent($sid);
}
# }}}


# resolve_session_to_ref {{{


sub resolve_session_to_ref {
	my $self = shift;
	my $sid = shift || $self->current_session()->ID;
	return $poe_kernel->_data_sid_resolve($sid);
}
# }}}

# resolve_session_to_id {{{


sub resolve_session_to_id {
    my $self = shift;
    my $session = shift || $self->current_session();
    return $poe_kernel->_data_ses_resolve_to_id($session);
}
# }}}

# get_session_refcount {{{


sub get_session_refcount {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_ses_refcount($sid);
}
# }}}

# session_count {{{


sub session_count {
	return $poe_kernel->_data_ses_count();
}
# }}}

# session_list {{{


sub session_list {
	my @sessions;
	my $kr_sessions = $POE::Kernel::poe_kernel->[POE::Kernel::KR_SESSIONS];
	foreach my $key ( keys %$kr_sessions ) {
		next if $key =~ /POE::Kernel/;
		push @sessions, $kr_sessions->{$key}->[0];
	}
	return @sessions;
}
# }}}

# session_memory_size {{{


sub session_memory_size {
	my $self = shift;
	my $session = shift || $self->current_session();
    $session = $poe_kernel->_data_sid_resolve($session) unless ref $session;
	return total_size($session);
}
# }}}}

# session_event_list {{{


sub session_event_list {
	my $self = shift;
	my $session = shift || $self->current_session();
	my @events = sort keys %{ $session->[ &POE::Session::SE_STATES() ] };

	if(wantarray) {
		return @events;
	} else {
		return \@events;
	}
}
# }}}

# }}}

# Alias fun {{{


# resolve_alias {{{


sub resolve_alias {
	my $self = shift;
	my $alias = shift or return undef;
	return $poe_kernel->_data_alias_resolve($alias);
}
# }}}

# session_alias_list {{{


sub session_alias_list {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_alias_list($sid);
}
# }}}

# session_alias_count {{{


sub session_alias_count {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_alias_count_ses($sid);
}
# }}}

# session_id_loggable {{{


sub session_id_loggable {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_alias_loggable($sid);
}
# }}}

# }}}

# Event fun {{{


sub event_count_to {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_ev_get_count_to($sid);
}
#}}}

# event_count_from {{{


sub event_count_from {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_ev_get_count_from($sid);
}

#}}}

# event_queue {{{


sub event_queue {
	return $poe_kernel->[POE::Kernel::KR_QUEUE]
}

# }}}

# event_queue_dump {{{


sub event_queue_dump {
	my $self = shift;
	my $queue = $self->event_queue;

	my @happy_queue;
	my @queue = $queue->peek_items(sub { return 1; });

	my $i = 0;
	foreach my $qitem (@queue) {
		my $item = {};
		my ($priority, $id, $payload) = @$qitem;

		$item->{ID} = $id;
		$item->{index} = $i++;
		$item->{priority} = $priority;

		my $ev_name = $payload->[POE::Kernel::EV_NAME()];
		$item->{event} = $ev_name;
		$item->{source} = $payload->[POE::Kernel::EV_SOURCE];
		$item->{destination} = $payload->[POE::Kernel::EV_SESSION];

		my $type = $payload->[POE::Kernel::EV_TYPE()];
		my $type_str;
		if ($type & POE::Kernel::ET_START()) {
			$type_str = '_start';
		} elsif ($type & POE::Kernel::ET_STOP()) {
			$type_str = '_stop';
		} elsif ($type & POE::Kernel::ET_SIGNAL()) {
			$type_str = '_signal';
		} elsif ($type & POE::Kernel::ET_GC()) {
			$type_str = '_garbage_collect';
		} elsif ($type & POE::Kernel::ET_PARENT()) {
			$type_str = '_parent';
		} elsif ($type & POE::Kernel::ET_CHILD()) {
			$type_str = '_child';
		} elsif ($type & POE::Kernel::ET_SCPOLL()) {
			$type_str = '_sigchld_poll';
		} elsif ($type & POE::Kernel::ET_ALARM()) {
			$type_str = 'Alarm';
		} elsif ($type & POE::Kernel::ET_SELECT()) {
			$type_str = 'File Activity';
		} else {
			if($type & POE::Kernel::ET_POST()) {
				$type_str = 'User';
			} elsif ($type & POE::Kernel::ET_CALL()) {
				$type_str = 'User (not enqueued)';
			} else {
				$type_str = 'Unknown';
			}
		}

		$item->{type} = $type_str;
		push @happy_queue, $item;
	}

	return @happy_queue;
} #}}}



# }}}

# Extref fun {{{


# extref_count {{{


sub extref_count {
	return $poe_kernel->_data_extref_count();
}
# }}}

# get_session_extref_count {{{


sub get_session_extref_count {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_extref_count_ses($sid);
}
# }}}

# }}}

# Filehandles Fun {{{


# is_handle_tracked {{{


sub is_handle_tracked {
	my($self, $handle, $mode) = @_;
	return $poe_kernel->_data_handle_is_good($handle, $mode);
}
# }}}

# handle_count {{{


sub handle_count {
	return $poe_kernel->_data_handle_count();
}
# }}}

# session_handle_count {{{


sub session_handle_count {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_handle_count_ses($sid);
}
# }}}

# }}}

# PID Fun {{{


# session_pid_count {{{


sub session_pid_count {
    my $self = shift;
    my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
    my $ver = $POE::VERSION;
    $ver =~ s/_.+$//;
    if($ver < '1.350') {
	   return $poe_kernel->_data_sig_pids_ses($sid);
	}
	carp "session_pid_count() is not available for POE 1.350 and above\n";
	return;
}

# }}}

# }}}


# Signals Fun {{{


# get_safe_signals {{{


sub get_safe_signals {
	return $poe_kernel->_data_sig_get_safe_signals();
}
# }}}

# get_signal_type {{{


sub get_signal_type {
	my $self = shift;
	my $sig = shift or return undef;
	return $poe_kernel->_data_sig_type($sig);
}
# }}}

# is_signal_watched {{{


sub is_signal_watched {
	my $self = shift;
	my $sig = shift or return undef;
	return $poe_kernel->_data_sig_explicitly_watched($sig);
}
# }}}

# signals_watched_by_session {{{


sub signals_watched_by_session {
	my $self = shift;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	my %sigs = $poe_kernel->_data_sig_watched_by_session($sid);

	my %ret;
	foreach my $k (keys %sigs) {
		my $ev = $sigs{$k}[0];
		$ret{$k} = $ev;
	}

	return %ret;
}
# }}}

# signal_watchers {{{


sub signal_watchers {
	my $self = shift;
	my $sig = shift or return undef;
	my %sigs = $poe_kernel->_data_sig_watchers($sig);

	my %ret;
	foreach my $k (keys %sigs) {
		my $ev = $sigs{$k}[0];
		$ret{$poe_kernel->alias_resolve($k)} = $ev;
	}

	return %ret;
}
# }}}

# is_signal_watched_by_session {{{


sub is_signal_watched_by_session {
	my $self = shift;
	my $signal = shift or return undef;
	my $session = shift || $self->current_session();
    my $sid = ref $session ? $session->ID : $session;
	return $poe_kernel->_data_sig_is_watched_by_session($signal, $sid);
}
# }}}

# }}}


1;


=pod

=head1 NAME

POE::API::Peek - Peek into the internals of a running POE environment

=head1 VERSION

version 2.20

=head1 DESCRIPTION

POE::API::Peek extends the POE::Kernel interface to provide clean access
to Kernel internals in a cross-version compatible manner. Other
calculated data is also available.

My intention is to provide massive amounts of internal data for use in
POE debugging.

=head1 WARNING

B<This version of this module is certified against POE version 1.300 and
above. It will fail on any other POE version.>

B<Further, this module requires perl v5.6.1 or above.>

=head1 METHODS

=cut

=pod


=head2 new

  my $api = POE::API::Peek->new();

Returns a blessed reference. Takes no parameters.

=cut

=pod


=head2 id

  my $foo = $api->id();

Obtain the unique id for the kernel. Takes no parameters. Returns a
scalar containing a string.

=cut

=pod

=head1 KERNEL UTILITIES

=cut

=pod


=head2 is_kernel_running

  if($api->is_kernel_running) {
      # do stuff...
  }

Tell if the POE Kernel is running and active. Returns 1 if the Kernel is
running and 0 if it is not.

=cut

=pod


=head2 active_event

  my $event = $api->active_event();

Get the active event name. Returns a string containing the event name.

=cut

=pod


=head2 kernel_memory_size

  my $size = $api->kernel_memory_size();

Get the memory footprint of the kernel and consequently the entire POE environment.
See the Devel::Size documentation for several caveats involved in this metric.

=cut

=pod


=head2 event_list

  my $events = $api->event_list();

Gets the list of events for the whole POE environment. Returns a hash
with the session IDs as the keys and a list of events as the
values.

=cut

=pod


=head2 which_loop

  my $loop_name = $api->which_loop();

Tell which Loop POE has decided to use. Returns the string name of the Loop
module.

=cut

=pod

=head1 SESSION UTILITIES

=cut

=pod


=head2 current_session

  my $foo = $api->current_session();

Get the POE::Session object for the currently active session. Takes no
parameters. Returns a scalar containing a reference.

=cut

=pod


=head2 get_session_children

    my @children = $api->get_session_children($session_id);
    my @children = $api->get_session_children();

Get the children (if any) for a given session. Takes one optional
parameter, a POE::Session object or ID. If this parameter is not provided, the
method defaults to the currently active session. Returns a list of
POE::Session objects.

=cut

=pod


=head2 is_session_child

  if($api->is_session_child($parent, $session_id)) { }
  if($api->is_session_child($parent, $session)) { }
  if($api->is_session_child($parent)) { }

Determine if POE::Session A is a child of POE::Session B. Takes one
mandatory parameter, a POE::Session object which is the potential parent
session this method will interrogate. Takes one optional parameter, a
POE::Session object which is the session whose parentage this method
will determine. If this parameter is not specified, it will default to
the currently active session. Returns a boolean.

=cut

=pod


=head2 get_session_parent

    my $parent = $api->get_session_parent($session_id);
    my $parent = $api->get_session_parent($session);
    my $parent = $api->get_session_parent();

Get the parent for a given session. Takes one optional parameter, a
POE::Session object or ID. If this parameter is not provided, the method
defaults to the currently active session. Returns a POE::Session object.

=cut

=pod


=head2 resolve_session_to_ref

  my $session = $api->resolve_session_to_ref($session_id);
  my $session = $api->resolve_session_to_ref();

Obtain a reference to a session given its ID. Takes one optional
parameter, a POE::Session ID. If this parameter is not specified, it
will default to the currently active session. Returns a reference to a
POE::Session object on success; undef on failure.

=cut

=pod


=head2 resolve_session_to_id

  my $session_id = $api->resolve_session_to_id($session);
  my $session_id = $api->resolve_session_to_id();

Obtain the session id for a given POE::Session object. Takes one
optional parameter, a POE::Session object or ID. If this parameter is not
specified, it will default to the currently active session. Returns an
integer on success and undef on failure.

=cut

=pod


=head2 get_session_refcount

  my $count = $api->get_session_refcount($session_id);
  my $count = $api->get_session_refcount($session);
  my $count = $api->get_session_refcount();

Obtain the reference count for a given POE::Session. Takes one optional
parameter, a POE::Session object or ID. If this parameter is not specified, it
will default to the currently active session. Returns an integer.

=cut

=pod


=head2 session_count

  my $count = $api->session_count();

Obtain a count of how many sessions exist. Takes no parameters. Returns
an integer.

Note: for various reasons, the Kernel counts as a session.

=cut

=pod


=head2 session_list

  my @sessions = $api->session_list();

Obtain a list of all the sessions that exist. Takes no parameters.
Returns a list populated with POE::Session objects.

Note: While the Kernel counts as a session, it has been extracted
from this list.

=cut

=pod


=head2 session_memory_size

  my $size = $api->session_memory_size();
  my $size = $api->session_memory_size($session);
  my $size = $api->session_memory_size($session_id);

Get the memory footprint of a session. If no session is provided, the current
session is used. See the Devel::Size documentation for several caveats
involved in this metric.

=cut

=pod


=head2 session_event_list

  my @events = $api->session_event_list();
  my $events = $api->session_event_list();
  my @events = $api->session_event_list($session);
  my $events = $api->session_event_list($session);
  my @events = $api->session_event_list($session_id);
  my $events = $api->session_event_list($session_id);

Get the list of events for a session. If no session is provided, the current
session is used.

=cut

=pod

=head1 ALIAS UTILITIES

=cut

=pod


=head2 resolve_alias

  my $session = $api->resolve_alias($session_alias);

Resolve a session alias into a POE::Session object. Takes one mandatory
parameter, a session alias. Returns a POE::Session object on success or
undef on failure.

=cut

=pod


=head2 session_alias_list

  my @aliases = $api->session_alias_list($session_id);
  my @aliases = $api->session_alias_list($session);
  my @aliases = $api->session_alias_list();

Obtain a list of aliases for a POE::Session object. Takes one optional
parameter, a POE::Session object or ID. If this parameter is not specified, it
will default to the currently active session. Returns a list of strings.

=cut

=pod


=head2 session_alias_count

  my $count = $api->session_alias_count($session_id);
  my $count = $api->session_alias_count($session);
  my $count = $api->session_alias_count();

Obtain the count of how many aliases a session has. Takes one optional
parameter, a POE::Session object or ID. If this parameter is not specified, it
will default to the currently active session. Returns an integer.

=cut

=pod


=head2 session_id_loggable

    my $str = $api->session_id_loggable($session_id);
    my $str = $api->session_id_loggable($session);
    my $str = $api->session_id_loggable();

Obtain a loggable version of a session id. Takes one optional parameter,
a POE::Session object or ID. If this parameter is not specified, it will
default to the currently active session. Returns a string.

=cut

=pod

=head1 EVENT UTILITIES

# event_count_to {{{

=head2 event_count_to

  my $count = $api->event_count_to($session_id);
  my $count = $api->event_count_to($session);
  my $count = $api->event_count_to();

Get the number of events heading toward a particular session. Takes one
parameter, a POE::Session object or ID. if none is provided, defaults to the
current session. Returns an integer.

=cut

=pod


=head2 event_count_from

  my $count = $api->get_session_extref_count($session_id);
  my $count = $api->event_count_from($session);
  my $count = $api->event_count_from();

Get the number of events heading out from a particular session. Takes one
parameter, a POE::Session object or ID. If none is provided, defaults to the
current session. Return an integer.

=cut

=pod


=head2 event_queue

  my $foo = $api->event_queue();

Access the internal event queue. Takes no parameters. Returns a scalar
containing a reference to a POE::Queue::Array object.

=cut

=pod


=head2 event_queue_dump

  my @queue = $api->event_queue_dump();

Dump the contents of the event queue in a nice understandable fashion.  Takes no
parameters. Returns a list of queue items. Each item is a hash containing the
following entries:

=over 4

=item * ID

The id number that POE's queue identifies this entry as.

=item * index

The index into the POE::Queue::Array which holds this entry.

=item * priority

The priority level this entry has.

=item * event

The name of this event

=item * source

What caused this event. Usually a POE::Session.

=item * destination

Where this event is headed. Usually a POE::Session.

=item * type

The type of event this is. May have the value User, _start, _stop, _signal,
_garbage_collect, _parent, _child, _sigchld_poll, Alarm, File Activity, or
Unknown.

=back

=cut

=pod

=head1 EXTREF UTILITIES

=cut

=pod


=head2 extref_count

  my $count = $api->extref_count();

Obtain a count of sessions with extra references. Takes no parameters.
Returns an integer.

=cut

=pod


=head2 get_session_extref_count

  my $count = $api->get_session_extref_count($session_id);
  my $count = $api->get_session_extref_count($session);
  my $count = $api->get_session_extref_count();

Obtain the number of extra references a session has. Takes one optional
parameter, a POE::Session object or ID. If this parameter is not specified, it
will default to the currently active session. Returns an integer.

=cut

=pod

=head1 FILEHANDLE UTILITIES

=cut

=pod


=head2 is_handle_tracked

  if($api->is_handle_tracked($handle, $mode)) { }

Determine if POE is tracking a handle. Takes two mandatory parameters, a
filehandle and a mode indicator. Returns a boolean.

=cut

=pod


=head2 handle_count

  my $count = $api->handle_count();

Obtain a count of how many handles POE is tracking. Takes no parameters.
Returns an integer.

=cut

=pod


=head2 session_handle_count

  my $count = $api->session_handle_count($session_id);
  my $count = $api->session_handle_count($session);
  my $count = $api->session_handle_count();

Obtain a count of the active handles for a given session. Takes one
optional parameter, a POE::Session object or ID. If this parameter is not
supplied, it will default to the currently active session.

=cut

=pod

=head1 PID UTILITIES

=cut

=pod


=head2 session_pid_count

    my $count = $api->session_pid_count($session_id);
    my $count = $api->session_pid_count($session);
    my $count = $api->session_pid_count();

Obtain a count of the process IDs being watched by a session. Takes one
optional parameter, a POE::Session object or ID. If this parameter is not
supplied, it will default to the currently active session.

Since 1.350 of L<POE> it is no longer possible to query the number of
processes a session is watching. This method is deprecated and will be
removed in a future version.

=cut

=pod

=head1 SIGNAL UTILITIES

POTENTIAL BREAKAGE NOTE: In POE v1.293 (in particular: svn rev 2916)
changed the structure of signals. Previously, the data portion of a
signal was simply the name of the event to be called. Now it contains a
data portion, continuation style arguments that may be passed on to the
signal handler.

See the L<POE::Kernel> documentation for more info.

=cut

=pod


=head2 get_safe_signals

  my @safe_signals = $api->get_safe_signals();

Obtain a list of signals which it is safe for POE to manipulate. Takes
no parameters. Returns a list of strings.

=cut

=pod


=head2 get_signal_type

  my $type = $api->get_signal_type($signal_name);

Figure out which type of signal this is. Signals can be one of three
types, BENIGN, TERMINAL, NONMASKABLE. The type value returned here,
corresponds to subroutine constants SIGTYPE_BENIGN, SIGTYPE_TERMINAL,
and SIGTYPE_NONMASKABLE in POE::Kernel's namespace. Takes one mandatory
parameter, a signal name.

=cut

=pod


=head2 is_signal_watched

  if($api->is_signal_watched($signal_name)) { }

Determine if a signal is being explicitly watched. Takes one mandatory
parameter, a signal name. Returns a boolean.

=cut

=pod


=head2 signals_watched_by_session

  my %signals = $api->signals_watched_by_session($session);
  my %signals = $api->signals_watched_by_session();

Get the signals watched by a session and the events they generate. Takes
one optional parameter, a POE::Session object or ID. If this parameter is not
supplied, it will default to the currently active session. Returns a
hash, with a signal name as the key and the event the session generates
as the value.

=cut

=pod


=head2 signal_watchers

  my %watchers = $api->signal_watchers($signal_name);

Get a list of the sessions watching a particular signal. Takes one
mandatory parameter, a signal name. Returns a hash, keyed by session
reference with an event name as the value.

=cut

=pod


=head2 is_signal_watched_by_session

  if($api->is_signal_watched_by_session($signal_name, $session_id)) { }
  if($api->is_signal_watched_by_session($signal_name, $session)) { }
  if($api->is_signal_watched_by_session($signal_name)) { }

Determine if a given session is explicitly watching a signal. Takes one
mandatory parameter, a signal name. Takes one optional parameter, a
POE::Session object or ID. If this parameter is not provided, it will default
to the currently active session. Returns a boolean.

=head1 AUTHORS

sungo <sungo@sungo.us>
Yuval Kogman <nothingmuch@woobling.org>
Chris 'BinGOs' Williams <bingos@cpan.org>
Philip Gwyn <gwyn@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2012 by Matt Cashner (sungo).

This is free software, licensed under:

  The (three-clause) BSD License

=cut


__END__

# sungo // vim: ts=4 sw=4 noet