OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_BIN_SOCKET_H_ | 5 #ifndef RUNTIME_BIN_SOCKET_H_ |
6 #define RUNTIME_BIN_SOCKET_H_ | 6 #define RUNTIME_BIN_SOCKET_H_ |
7 | 7 |
8 #if defined(DART_IO_DISABLED) | 8 #if defined(DART_IO_DISABLED) |
9 #error "socket.h can only be included on builds with IO enabled" | 9 #error "socket.h can only be included on builds with IO enabled" |
10 #endif | 10 #endif |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 static void* GetHashmapKeyFromIntptr(intptr_t i) { | 460 static void* GetHashmapKeyFromIntptr(intptr_t i) { |
461 return reinterpret_cast<void*>(i + 1); | 461 return reinterpret_cast<void*>(i + 1); |
462 } | 462 } |
463 | 463 |
464 OSSocket* LookupByPort(intptr_t port); | 464 OSSocket* LookupByPort(intptr_t port); |
465 void InsertByPort(intptr_t port, OSSocket* socket); | 465 void InsertByPort(intptr_t port, OSSocket* socket); |
466 void RemoveByPort(intptr_t port); | 466 void RemoveByPort(intptr_t port); |
467 | 467 |
468 OSSocket* LookupByFd(intptr_t fd); | 468 OSSocket* LookupByFd(intptr_t fd); |
469 void InsertByFd(intptr_t fd, OSSocket* socket); | 469 void InsertByFd(intptr_t fd, OSSocket* socket); |
470 void RemoveByFd(intptr_t fd); | |
471 | 470 |
472 bool CloseOneSafe(OSSocket* os_socket); | 471 // If `map_cursor` is provided it will be updated to point to the next |
| 472 // element (in iteration order of `sockets_by_fd`) after `fd` was removed. |
| 473 void RemoveByFd(intptr_t fd, HashMap::Entry** map_cursor); |
| 474 |
| 475 bool CloseOneSafe(OSSocket* os_socket, HashMap::Entry** fd_map_cursor); |
473 void CloseAllSafe(); | 476 void CloseAllSafe(); |
474 | 477 |
475 HashMap sockets_by_port_; | 478 HashMap sockets_by_port_; |
476 HashMap sockets_by_fd_; | 479 HashMap sockets_by_fd_; |
477 | 480 |
478 Mutex* mutex_; | 481 Mutex* mutex_; |
479 | 482 |
480 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry); | 483 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry); |
481 }; | 484 }; |
482 | 485 |
483 } // namespace bin | 486 } // namespace bin |
484 } // namespace dart | 487 } // namespace dart |
485 | 488 |
486 #endif // RUNTIME_BIN_SOCKET_H_ | 489 #endif // RUNTIME_BIN_SOCKET_H_ |
OLD | NEW |