Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::udt_epoll_service Class Reference

Public Member Functions

 udt_epoll_service ()
 
 ~udt_epoll_service ()
 
void poll_loop ()
 
void notify_read (int udt_socket_id, const promise< void >::ptr &p)
 
void notify_write (int udt_socket_id, const promise< void >::ptr &p)
 
void remove (int udt_socket_id)
 

Detailed Description

Definition at line 25 of file udt_socket.cpp.

Constructor & Destructor Documentation

◆ udt_epoll_service()

fc::udt_epoll_service::udt_epoll_service ( )
inline

Definition at line 28 of file udt_socket.cpp.

29 :_epoll_thread("udt_epoll")
30 {
31 UDT::startup();
33 _epoll_id = UDT::epoll_create();
34 _epoll_loop = _epoll_thread.async( [=](){ poll_loop(); }, "udt_poll_loop" );
35 }
void check_udt_errors()
Here is the call graph for this function:

◆ ~udt_epoll_service()

fc::udt_epoll_service::~udt_epoll_service ( )
inline

Definition at line 37 of file udt_socket.cpp.

38 {
39 _epoll_loop.cancel("udt_epoll_service is destructing");
40 _epoll_loop.wait();
41 UDT::cleanup();
42 }

Member Function Documentation

◆ notify_read()

void fc::udt_epoll_service::notify_read ( int udt_socket_id,
const promise< void >::ptr & p )
inline

Definition at line 81 of file udt_socket.cpp.

83 {
84 int events = UDT_EPOLL_IN | UDT_EPOLL_ERR;
85 if( 0 != UDT::epoll_add_usock( _epoll_id,
86 udt_socket_id,
87 &events ) )
88 {
90 }
91 { synchronized(_read_promises_mutex)
92
93 _read_promises[udt_socket_id] = p;
94 }
95 }
const mie::Vuint & p
Definition bn.cpp:27
Here is the call graph for this function:

◆ notify_write()

void fc::udt_epoll_service::notify_write ( int udt_socket_id,
const promise< void >::ptr & p )
inline

Definition at line 97 of file udt_socket.cpp.

99 {
100 int events = UDT_EPOLL_OUT | UDT_EPOLL_ERR;
101 if( 0 != UDT::epoll_add_usock( _epoll_id,
102 udt_socket_id,
103 &events ) )
104 {
106 }
107
108 { synchronized(_write_promises_mutex)
109 _write_promises[udt_socket_id] = p;
110 }
111 }
Here is the call graph for this function:

◆ poll_loop()

void fc::udt_epoll_service::poll_loop ( )
inline

Definition at line 44 of file udt_socket.cpp.

45 {
46 std::set<UDTSOCKET> read_ready;
47 std::set<UDTSOCKET> write_ready;
48 while( !_epoll_loop.canceled() )
49 {
50 UDT::epoll_wait( _epoll_id,
51 &read_ready,
52 &write_ready, 100000000 );
53
54 { synchronized(_read_promises_mutex)
55 for( auto sock : read_ready )
56 {
57 auto itr = _read_promises.find( sock );
58 if( itr != _read_promises.end() )
59 {
60 itr->second->set_value();
61 _read_promises.erase(itr);
62 }
63 }
64 } // synchronized read promise mutex
65
66 { synchronized(_write_promises_mutex)
67 for( auto sock : write_ready )
68 {
69 auto itr = _write_promises.find( sock );
70 if( itr != _write_promises.end() )
71 {
72 itr->second->set_value();
73 _write_promises.erase(itr);
74 }
75 }
76 } // synchronized write promise mutex
77 } // while not canceled
78 } // poll_loop
Here is the caller graph for this function:

◆ remove()

void fc::udt_epoll_service::remove ( int udt_socket_id)
inline

Definition at line 112 of file udt_socket.cpp.

113 {
114 { synchronized(_read_promises_mutex)
115 auto read_itr = _read_promises.find( udt_socket_id );
116 if( read_itr != _read_promises.end() )
117 {
118 read_itr->second->set_exception( fc::copy_exception( fc::exception() ) );
119 _read_promises.erase(read_itr);
120 }
121 }
122 { synchronized(_write_promises_mutex)
123 auto write_itr = _write_promises.find( udt_socket_id );
124 if( write_itr != _write_promises.end() )
125 {
126 write_itr->second->set_exception( fc::copy_exception( fc::exception() ) );
127 _write_promises.erase(write_itr);
128 }
129 }
130 UDT::epoll_remove_usock( _epoll_id, udt_socket_id );
131 }
Used to generate a useful error report when an exception is thrown.
Definition exception.hpp:58
fc::exception_ptr copy_exception(T &&e)
Here is the call graph for this function:

The documentation for this class was generated from the following file: