| 96 | // ---------------------------------------------------------------------------------------- |
| 97 | |
| 98 | void linker:: |
| 99 | link ( |
| 100 | connection& a, |
| 101 | connection& b |
| 102 | ) |
| 103 | { |
| 104 | // make sure requires clause is not broken |
| 105 | DLIB_CASSERT( |
| 106 | this->is_running() == false , |
| 107 | "\tvoid linker::link" |
| 108 | << "\n\tis_running() == " << this->is_running() |
| 109 | << "\n\tthis: " << this |
| 110 | ); |
| 111 | |
| 112 | running_mutex.lock(); |
| 113 | running = true; |
| 114 | running_mutex.unlock(); |
| 115 | |
| 116 | cons_mutex.lock(); |
| 117 | A = &a; |
| 118 | B = &b; |
| 119 | cons_mutex.unlock(); |
| 120 | |
| 121 | |
| 122 | |
| 123 | service_connection_running_mutex.lock(); |
| 124 | service_connection_running = true; |
| 125 | service_connection_running_mutex.unlock(); |
| 126 | |
| 127 | service_connection_error_mutex.lock(); |
| 128 | service_connection_error = false; |
| 129 | service_connection_error_mutex.unlock(); |
| 130 | |
| 131 | // if we fail to make the thread |
| 132 | if (!create_new_thread(service_connection,this)) |
| 133 | { |
| 134 | a.shutdown(); |
| 135 | b.shutdown(); |
| 136 | |
| 137 | service_connection_running_mutex.lock(); |
| 138 | service_connection_running = false; |
| 139 | service_connection_running_mutex.unlock(); |
| 140 | |
| 141 | cons_mutex.lock(); |
| 142 | A = 0; |
| 143 | B = 0; |
| 144 | cons_mutex.unlock(); |
| 145 | |
| 146 | running_mutex.lock(); |
| 147 | running = false; |
| 148 | running_mutex.unlock(); |
| 149 | |
| 150 | |
| 151 | |
| 152 | throw dlib::thread_error ( |
| 153 | ECREATE_THREAD, |
| 154 | "failed to make new thread in linker::link()" |
| 155 | ); |
nothing calls this directly
no test coverage detected