summaryrefslogtreecommitdiff
path: root/distbuild/eventsrc.py
blob: 560b9b7a3e92d8924f3f83758000d6698ccd7bf7 (plain)
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
# mainloop/eventsrc.py -- interface for event sources
#
# Copyright (C) 2012, 2014  Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA..


class EventSource(object):

    '''A source of events for state machines.
    
    This is a base class.
    
    An event source watches one file descriptor, and returns events
    related to it. The events may vary depending on the file descriptor.
    The actual watching is done using select.select.
    
    '''
    
    def get_select_params(self):
        '''Return parameters to use for select for this event source.
        
        Three lists of file descriptors, and a timeout are returned.
        The three lists and the timeout are used as arguments to the 
        select.select function, though they may be manipulated and
        combined with return values from other event sources.
        
        '''
        
        return [], [], [], None

    def get_events(self, r, w, x):
        '''Return events related to this file descriptor.
        
        The arguments are the return values of select.select.
        
        '''
        
        return []

    def is_finished(self):
        '''Is this event source finished?
        
        It's finished if it won't ever return any new events.
        
        '''
        
        return False