Changeset f421190


Ignore:
Timestamp:
Mar 14, 2012, 12:57:21 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Children:
5832433
Parents:
d474ee9
git-author:
David Benjamin <davidben@mit.edu> (03/13/12 14:05:14)
git-committer:
David Benjamin <davidben@mit.edu> (03/14/12 12:57:21)
Message:
Load Jabber implementation lazily

Brings our startup RSS down from about 45MB to 32MB. Fixes #213.
Location:
perl/modules/Jabber/lib/BarnOwl/Module
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    rd474ee9 rf421190  
    1616use BarnOwl;
    1717use BarnOwl::Hooks;
    18 use BarnOwl::Module::Jabber::Impl;
    1918
    2019use utf8;
    2120
    2221our $VERSION = 0.1;
     22
     23our $impl_loaded;
     24$impl_loaded = 0 unless defined($impl_loaded);
     25
     26sub _load_impl {
     27    unless ($impl_loaded) {
     28        BarnOwl::debug("_load_impl");
     29        require BarnOwl::Module::Jabber::Impl;
     30        $impl_loaded = 1;
     31        BarnOwl::Module::Jabber::Impl::onStart();
     32    }
     33}
    2334
    2435sub onStart {
     
    5162                                });
    5263
    53         BarnOwl::Module::Jabber::Impl::onStart();
     64        # If we're called as part of module reload, let Impl's reload
     65        # code run too.
     66        if ($impl_loaded) {
     67            BarnOwl::Module::Jabber::Impl::onStart();
     68        }
    5469    } else {
    5570        # Our owl doesn't support queue_message. Unfortunately, this
     
    6479    my $func = shift;
    6580    return sub {
     81        _load_impl();
    6682        no strict 'refs';
    6783        &{"BarnOwl::Module::Jabber::Impl::$func"};
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Impl.pm

    rd474ee9 rf421190  
    4545
    4646no warnings 'redefine';
     47
     48BarnOwl::debug("BarnOwl::Module::Jabber::Impl loaded");
    4749
    4850################################################################################
Note: See TracChangeset for help on using the changeset viewer.