+# this is the main commutator loop. In due course it will
+# become the *only* commutator loop
+sub process
+{
+ my $thing;
+ while (@queue) {
+ $thing = shift @queue;
+ my $dxchan = DXChannel->get($thing->{dxchan});
+ if ($dxchan) {
+ if ($thing->can('in_filter')) {
+ next unless $thing->in_filter($dxchan);
+ }
+
+ # remember any useful routes
+ RouteDB::update($thing->{origin}, $dxchan->{call}, $thing->{hopsaway});
+ RouteDB::update($thing->{user}, $dxchan->{call}, $thing->{hopsaway}) if exists $thing->{user};
+
+ $thing->handle($dxchan);
+ }
+ }
+
+ # per second and per minute processing
+ if ($main::systime != $lastsec) {
+ if ($main::systime >= $lastmin+60) {
+ foreach my $r (@permin) {
+ &{$r->[0]}();
+ }
+ $lastmin = $main::systime;
+ }
+ foreach my $r (@persec) {
+ &{$r->[0]}();
+ }
+ $lastsec = $main::systime;
+ }
+}
+
+sub add_minute_process
+{
+ my $pkg = shift;
+ my $addr = shift;
+ my $name = shift;
+ dbg('Adding $name to Thingy per minute queue');
+ push @permin, [$addr, $name];
+}
+
+sub add_second_process
+{
+ my $pkg = shift;
+ my $addr = shift;
+ my $name = shift;
+ dbg('Adding $name to Thingy per second queue');
+ push @persec, [$addr, $name];
+}
+
+
+sub ascii
+{
+ my $thing = shift;
+ my $dd = new Data::Dumper([$thing]);
+ $dd->Indent(0);
+ $dd->Terse(1);
+ $dd->Sortkeys(1);
+ $dd->Quotekeys($] < 5.005 ? 1 : 0);
+ return $dd->Dumpxs;
+}