Changeset 120dac7


Ignore:
Timestamp:
Aug 8, 2013, 2:38:50 PM (11 years ago)
Author:
Edward Z. Yang <ezyang@mit.edu>
Branches:
master, release-1.10
Children:
ecd4edf
Parents:
a38becd
git-author:
Jason Gross <jgross@mit.edu> (07/21/11 18:17:41)
git-committer:
Edward Z. Yang <ezyang@mit.edu> (08/08/13 14:38:50)
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 r120dac7  
    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 r120dac7  
    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 r120dac7  
    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

    ra38becd r120dac7  
    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.