Repository: oatpp/oatpp
File: src/oatpp/network/server/Server.hpp (C++)

Code before:
   * Status constant.
   */
  static const v_int32 STATUS_STOPPING;

  /**
   * Status constant.
   */
  static const v_int32 STATUS_DONE;

  /**
   * Create shared Server.
   * @param connectionProvider - &id:oatpp::network::ConnectionProvider;.
   * @param connectionHandler - &id:oatpp::network::server::ConnectionHandler;.
   * @return - `std::shared_ptr` to Server.
   */
  static std::shared_ptr<Server> createShared(const std::shared_ptr<ServerConnectionProvider>& connectionProvider,
                                              const std::shared_ptr<ConnectionHandler>& connectionHandler){
    return std::make_shared<Server>(connectionProvider, connectionHandler);
  }

  /**
   * Call &id:oatpp::network::ConnectionProvider::getConnection; in the loop and passes obtained Connection
   * to &id:oatpp::network::server::ConnectionHandler;.
   * @param blocking - Start the server blocking (thread of callee) or non-blocking (own thread)
   */
  void run(bool blocking = true);

  /**
   * Break server loop.
   * Note: thread can still be blocked on the &l:Server::run (); call as it may be waiting for ConnectionProvider to provide connection.
   */
  void stop();

  /**
   * Get server status.
   * @return - one of:<br>
   * <ul>
   *   <li>&l:Server::STATUS_CREATED;</li>
   *   <li>&l:Server::STATUS_RUNNING;</li>
   *   <li>&l:Server::STATUS_STOPPING;</li>
   *   <li>&l:Server::STATUS_DONE;</li>
   * </ul>
   */
  v_int32 getStatus();
  
};

  
}}}

#endif /* network_server_Server_hpp */

Review comment (suggestion):
The name "blocking"/"non-blocking" is confusing to me in this context.
I think it's better to describe exactly what it's going to do:

```cpp
Server::run(bool createNewThread);
```


Code after:
  /**
   * Status constant.
   */
  static const v_int32 STATUS_STOPPING;

  /**
   * Status constant.
   */
  static const v_int32 STATUS_DONE;

  /**
   * Create shared Server.
   * @param connectionProvider - &id:oatpp::network::ConnectionProvider;.
   * @param connectionHandler - &id:oatpp::network::server::ConnectionHandler;.
   * @return - `std::shared_ptr` to Server.
   */
  static std::shared_ptr<Server> createShared(const std::shared_ptr<ServerConnectionProvider>& connectionProvider,
                                              const std::shared_ptr<ConnectionHandler>& connectionHandler){
    return std::make_shared<Server>(connectionProvider, connectionHandler);
  }

  /**
   * Call &id:oatpp::network::ConnectionProvider::getConnection; in the loop and passes obtained Connection
   * to &id:oatpp::network::server::ConnectionHandler;.
   * @param startAsNewThread - Start the server blocking (thread of callee) or non-blocking (own thread)
   */
  void run(bool startAsNewThread = false);

  /**
   * Break server loop.
   * Note: thread can still be blocked on the &l:Server::run (); call as it may be waiting for ConnectionProvider to provide connection.
   */
  void stop();

  /**
   * Get server status.
   * @return - one of:<br>
   * <ul>
   *   <li>&l:Server::STATUS_CREATED;</li>
   *   <li>&l:Server::STATUS_RUNNING;</li>
   *   <li>&l:Server::STATUS_STOPPING;</li>
   *   <li>&l:Server::STATUS_DONE;</li>
   * </ul>
   */
  v_int32 getStatus();
  
};

  
}}}