5 ### (c) 2005 Straylight/Edgeware
8 ###----- Licensing notice ---------------------------------------------------
10 ### This file is part of the Python interface to mLib.
12 ### mLib/Python is free software; you can redistribute it and/or modify
13 ### it under the terms of the GNU General Public License as published by
14 ### the Free Software Foundation; either version 2 of the License, or
15 ### (at your option) any later version.
17 ### mLib/Python is distributed in the hope that it will be useful,
18 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ### GNU General Public License for more details.
22 ### You should have received a copy of the GNU General Public License
23 ### along with mLib/Python; if not, write to the Free Software Foundation,
24 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 SEL_WRITE = _SEL_WRITE
32 SelFile(FILE, [mode = SEL_READ], [readyproc = None])
34 Register a file (or socket, or, ...) with the select loop.
38 cdef readonly unsigned mode
40 def __cinit__(me, fd, int mode = SEL_READ, readyproc = None,
42 if (mode != _SEL_READ and
43 mode != _SEL_WRITE and
45 raise ValueError, 'bad select mode'
46 sel_initfile(&_sel, &me.f, _getfd(fd), mode, _filefunc, <void *>me)
49 me._readyfunc = _checkcallable(readyproc, 'ready proc')
54 """SF.fd -> INT: the file descriptor"""
58 """SF.activep -> BOOL: is the descriptor active?"""
60 return _tobool(me._activep)
62 """SF.readyproc -> FUNC: call FUNC() when file is ready for I/O"""
65 def __set__(me, proc):
66 me._readyfunc = _checkcallable(proc, 'ready proc')
70 """SF.enable(): enable waiting on file"""
72 raise ValueError, 'already enabled'
77 """SF.disable(): disable waiting on file"""
79 raise ValueError, 'already disabled'
84 """SF.force(): artificially mark file as ready"""
94 """SF.enabled(): called when file is enabled"""
97 """SF.disabled(): called when file is disabled"""
100 """SF.ready(): called when file is ready for I/O"""
101 return _maybecall(me._readyfunc, ())
103 cdef void _filefunc(int fd, unsigned mode, void *arg):
108 ###----- That's all, folks --------------------------------------------------