henrike@webrtc.org | f7795df | 2014-05-13 18:00:26 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_BASE_SOCKETSERVER_H_ |
| 12 | #define WEBRTC_BASE_SOCKETSERVER_H_ |
| 13 | |
| 14 | #include "webrtc/base/socketfactory.h" |
| 15 | |
| 16 | namespace rtc { |
| 17 | |
| 18 | class MessageQueue; |
| 19 | |
| 20 | // Provides the ability to wait for activity on a set of sockets. The Thread |
| 21 | // class provides a nice wrapper on a socket server. |
| 22 | // |
| 23 | // The server is also a socket factory. The sockets it creates will be |
| 24 | // notified of asynchronous I/O from this server's Wait method. |
| 25 | class SocketServer : public SocketFactory { |
| 26 | public: |
| 27 | // When the socket server is installed into a Thread, this function is |
| 28 | // called to allow the socket server to use the thread's message queue for |
| 29 | // any messaging that it might need to perform. |
| 30 | virtual void SetMessageQueue(MessageQueue* queue) {} |
| 31 | |
| 32 | // Sleeps until: |
| 33 | // 1) cms milliseconds have elapsed (unless cms == kForever) |
| 34 | // 2) WakeUp() is called |
| 35 | // While sleeping, I/O is performed if process_io is true. |
| 36 | virtual bool Wait(int cms, bool process_io) = 0; |
| 37 | |
| 38 | // Causes the current wait (if one is in progress) to wake up. |
| 39 | virtual void WakeUp() = 0; |
| 40 | }; |
| 41 | |
| 42 | } // namespace rtc |
| 43 | |
| 44 | #endif // WEBRTC_BASE_SOCKETSERVER_H_ |