| 471 | } |
| 472 | |
| 473 | int start_loop(bool block) override { |
| 474 | if (check_running()) |
| 475 | LOG_ERROR_RETURN(EALREADY, -1, "Already listening"); |
| 476 | m_block_serv = block; |
| 477 | if (block) return accept_loop(); |
| 478 | auto loop = &RSocketServer::accept_loop; |
| 479 | auto th = photon::thread_create((photon::thread_entry&)loop, this); |
| 480 | thread_enable_join(th); |
| 481 | thread_yield_to(th); |
| 482 | return 0; |
| 483 | } |
| 484 | void terminate() final { |
| 485 | photon::thread* th = workth.exchange(nullptr); |
| 486 | if (!th) return; |