Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 """Interfaces for platform-specific functionality.
00018
00019 This module exists primarily for documentation purposes and as base classes
00020 for other tornado.platform modules. Most code should import the appropriate
00021 implementation from `tornado.platform.auto`.
00022 """
00023
00024 from __future__ import absolute_import, division, print_function, with_statement
00025
00026
00027 def set_close_exec(fd):
00028 """Sets the close-on-exec bit (``FD_CLOEXEC``)for a file descriptor."""
00029 raise NotImplementedError()
00030
00031
00032 class Waker(object):
00033 """A socket-like object that can wake another thread from ``select()``.
00034
00035 The `~tornado.ioloop.IOLoop` will add the Waker's `fileno()` to
00036 its ``select`` (or ``epoll`` or ``kqueue``) calls. When another
00037 thread wants to wake up the loop, it calls `wake`. Once it has woken
00038 up, it will call `consume` to do any necessary per-wake cleanup. When
00039 the ``IOLoop`` is closed, it closes its waker too.
00040 """
00041 def fileno(self):
00042 """Returns the read file descriptor for this waker.
00043
00044 Must be suitable for use with ``select()`` or equivalent on the
00045 local platform.
00046 """
00047 raise NotImplementedError()
00048
00049 def write_fileno(self):
00050 """Returns the write file descriptor for this waker."""
00051 raise NotImplementedError()
00052
00053 def wake(self):
00054 """Triggers activity on the waker's file descriptor."""
00055 raise NotImplementedError()
00056
00057 def consume(self):
00058 """Called after the listen has woken up to do any necessary cleanup."""
00059 raise NotImplementedError()
00060
00061 def close(self):
00062 """Closes the waker's file descriptor(s)."""
00063 raise NotImplementedError()