diff options
-rw-r--r-- | fnet/src/vespa/fnet/transport.cpp | 12 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/transport.h | 4 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/transport_thread.cpp | 2 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/transport_thread.h | 49 |
4 files changed, 25 insertions, 42 deletions
diff --git a/fnet/src/vespa/fnet/transport.cpp b/fnet/src/vespa/fnet/transport.cpp index dfeb8d03436..80dfd118c20 100644 --- a/fnet/src/vespa/fnet/transport.cpp +++ b/fnet/src/vespa/fnet/transport.cpp @@ -201,18 +201,6 @@ FNET_Transport::GetTimeSampler() { return _threads[0]->GetTimeSampler(); } -bool -FNET_Transport::InitEventLoop() { - assert(_threads.size() == 1); - return _threads[0]->InitEventLoop(); -} - -bool -FNET_Transport::EventLoopIteration() { - assert(_threads.size() == 1); - return _threads[0]->EventLoopIteration(); -} - void FNET_Transport::Main() { assert(_threads.size() == 1); diff --git a/fnet/src/vespa/fnet/transport.h b/fnet/src/vespa/fnet/transport.h index 15e69bd66a6..4624c183b01 100644 --- a/fnet/src/vespa/fnet/transport.h +++ b/fnet/src/vespa/fnet/transport.h @@ -276,11 +276,9 @@ public: //------------------------------------------------------------------------- // single-threaded API forwarding. num_threads must be 1. Note: Choose - // only one of: (a) Start, (b) Main, (c) InitEventLoop + EventLoopIteration + // only one of: (a) Start, (b) Main // ------------------------------------------------------------------------- FastOS_TimeInterface *GetTimeSampler(); - bool InitEventLoop(); - bool EventLoopIteration(); void Main(); }; diff --git a/fnet/src/vespa/fnet/transport_thread.cpp b/fnet/src/vespa/fnet/transport_thread.cpp index 9e7a34209b4..9f47a2f0600 100644 --- a/fnet/src/vespa/fnet/transport_thread.cpp +++ b/fnet/src/vespa/fnet/transport_thread.cpp @@ -154,7 +154,6 @@ void FNET_TransportThread::SafeDiscardEvent(FNET_ControlPacket *cpacket, FNET_Context context) { - WaitFinished(); // make sure actual thread is all done std::lock_guard guard(_pseudo_thread); // be the thread DiscardEvent(cpacket, context); } @@ -638,6 +637,7 @@ FNET_TransportThread::Main() void FNET_TransportThread::Run(FastOS_ThreadInterface *thisThread, void *) { + std::lock_guard guard(_pseudo_thread); // be the thread if (!InitEventLoop()) { LOG(warning, "Transport: Run: Could not init event loop"); return; diff --git a/fnet/src/vespa/fnet/transport_thread.h b/fnet/src/vespa/fnet/transport_thread.h index 4de82d802dd..86c7cf1dfcd 100644 --- a/fnet/src/vespa/fnet/transport_thread.h +++ b/fnet/src/vespa/fnet/transport_thread.h @@ -149,6 +149,28 @@ private: void handle_add_cmd(FNET_IOComponent *ioc); void handle_close_cmd(FNET_IOComponent *ioc); + /** + * This method is called to initialize the transport thread event + * loop. It is called from the FRT_Transport::Run method. If you + * want to customize the event loop, you should do this by invoking + * this method once, then invoke the @ref EventLoopIteration method + * until it returns false (indicating transport shutdown). + * + * @return true on success, false on failure. + **/ + bool InitEventLoop(); + + /** + * Perform a single transport thread event loop iteration. This + * method is called by the FRT_Transport::Run method. If you want to + * customize the event loop, you should do this by invoking the @ref + * InitEventLoop method once, then invoke this method until it + * returns false (indicating transport shutdown). + * + * @return true when active, false after shutdown. + **/ + bool EventLoopIteration(); + public: /** * Construct a transport object. To activate your newly created @@ -478,35 +500,12 @@ public: void WaitFinished(); - /** - * This method is called to initialize the transport thread event - * loop. It is called from the FRT_Transport::Run method. If you - * want to customize the event loop, you should do this by invoking - * this method once, then invoke the @ref EventLoopIteration method - * until it returns false (indicating transport shutdown). - * - * @return true on success, false on failure. - **/ - bool InitEventLoop(); - - // selector call-back for selector wakeup void handle_wakeup(); // selector call-back for io-events void handle_event(FNET_IOComponent &ctx, bool read, bool write); - /** - * Perform a single transport thread event loop iteration. This - * method is called by the FRT_Transport::Run method. If you want to - * customize the event loop, you should do this by invoking the @ref - * InitEventLoop method once, then invoke this method until it - * returns false (indicating transport shutdown). - * - * @return true when active, false after shutdown. - **/ - bool EventLoopIteration(); - /** * Start transport layer operation in a separate thread. Note that @@ -529,9 +528,7 @@ public: /** * This is where the transport thread lives, when started by - * invoking one of the @ref Main or @ref Start methods. If you want - * to combine the FNET event loop with your own, you may use the - * @ref InitEventLoop and @ref EventLoopIteration methods directly. + * invoking one of the @ref Main or @ref Start methods. **/ void Run(FastOS_ThreadInterface *thisThread, void *args) override; }; |