Changeset 840e9b5


Ignore:
Timestamp:
Aug 7, 2013, 7:53:31 PM (8 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
94eb15b
Parents:
db798a2
git-author:
Jason Gross <jgross@mit.edu> (07/21/11 18:17:41)
git-committer:
Jason Gross <jgross@mit.edu> (08/07/13 19:53:31)
Message:
Added a hook for wakeup/user input.

I wanted to add a hook that got called on all user-input, but any
non-trivial use of that hook incurred too much overhead (about 7 ms per
paragraph for entry into perl, and another 100 ms or so per paragraph
for execution of the hook; tests run on pasting lorem ipusm, on
linerva).

This hook is called at most once a second (approximately).
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r6383920 r840e9b5  
    5656  g->starttime=time(NULL); /* assumes we call init only a start time */
    5757  g->lastinputtime=g->starttime;
     58  g->last_wakeup_time = g->starttime;
    5859  g->newmsgproc_pid=0;
    5960 
     
    482483time_t owl_global_get_idletime(const owl_global *g) {
    483484  return(time(NULL)-g->lastinputtime);
     485}
     486
     487void owl_global_wakeup(owl_global *g)
     488{
     489  if (time(NULL) - g->last_wakeup_time >= 1) {
     490    g_free(owl_perlconfig_execute("BarnOwl::Hooks::_wakeup()"));
     491    g->last_wakeup_time = time(NULL);
     492  }
    484493}
    485494
  • owl.c

    r499224d r840e9b5  
    289289
    290290  owl_global_set_lastinputtime(&g, time(NULL));
     291  owl_global_wakeup(&g);
    291292  ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
    292293  if (ret!=0 && ret!=1) {
  • owl.h

    r6249a88f r840e9b5  
    571571  time_t starttime;
    572572  time_t lastinputtime;
     573  time_t last_wakeup_time;
    573574  char *startupargs;
    574575  int nextmsgid;
  • perl/lib/BarnOwl/Hooks.pm

    rdb798a2 r840e9b5  
    3535
    3636Called before BarnOwl shutdown
     37
     38=item $wakeup
     39
     40Called, at most once per second, on user input
    3741
    3842=item $receiveMessage
     
    8892
    8993our @EXPORT_OK = qw($startup $shutdown
     94                    $wakeup
    9095                    $receiveMessage $newMessage
    9196                    $mainLoop $getBuddyList
     
    99104our $startup = BarnOwl::Hook->new;
    100105our $shutdown = BarnOwl::Hook->new;
     106our $wakeup = BarnOwl::Hook->new;
    101107our $receiveMessage = BarnOwl::Hook->new;
    102108our $newMessage = BarnOwl::Hook->new;
     
    194200}
    195201
     202sub _wakeup {
     203    $wakeup->run;
     204}
     205
    196206sub _receive_msg {
    197207    my $m = shift;
Note: See TracChangeset for help on using the changeset viewer.