OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/tools/epoll_server/epoll_server.h" | 5 #include "net/tools/epoll_server/epoll_server.h" |
6 | 6 |
7 #include <unistd.h> // For read, pipe, close and write. | 7 #include <unistd.h> // For read, pipe, close and write. |
8 #include <stdlib.h> // for abort | 8 #include <stdlib.h> // for abort |
9 #include <errno.h> // for errno and strerror_r | 9 #include <errno.h> // for errno and strerror_r |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/timer/timer.h" | 15 #include "base/time/time.h" |
16 | 16 |
17 // Design notes: An efficient implementation of ready list has the following | 17 // Design notes: An efficient implementation of ready list has the following |
18 // desirable properties: | 18 // desirable properties: |
19 // | 19 // |
20 // A. O(1) insertion into/removal from the list in any location. | 20 // A. O(1) insertion into/removal from the list in any location. |
21 // B. Once the callback is found by hash lookup using the fd, the lookup of | 21 // B. Once the callback is found by hash lookup using the fd, the lookup of |
22 // corresponding entry in the list is O(1). | 22 // corresponding entry in the list is O(1). |
23 // C. Safe insertion into/removal from the list during list iteration. (The | 23 // C. Safe insertion into/removal from the list during list iteration. (The |
24 // ready list's purpose is to enable completely event driven I/O model. | 24 // ready list's purpose is to enable completely event driven I/O model. |
25 // Thus, all the interesting bits happen in the callback. It is critical | 25 // Thus, all the interesting bits happen in the callback. It is critical |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 | 811 |
812 // If the alarm was registered, unregister it. | 812 // If the alarm was registered, unregister it. |
813 void EpollAlarm::UnregisterIfRegistered() { | 813 void EpollAlarm::UnregisterIfRegistered() { |
814 if (!registered_) { | 814 if (!registered_) { |
815 return; | 815 return; |
816 } | 816 } |
817 eps_->UnregisterAlarm(token_); | 817 eps_->UnregisterAlarm(token_); |
818 } | 818 } |
819 | 819 |
820 } // namespace net | 820 } // namespace net |
OLD | NEW |