@@ -21,10 +21,11 @@ # error No sockets available! #endif OF_ASSUME_NONNULL_BEGIN +@class OFArray; @class OFHTTPRequest; @class OFHTTPResponse; @class OFHTTPServer; @class OFStream; @class OFTCPSocket; @@ -97,51 +98,88 @@ OFString *_Nullable _certificateFile, *_Nullable _privateKeyFile; const char *_Nullable _privateKeyPassphrase; id _Nullable _delegate; OFString *_Nullable _name; OF_KINDOF(OFTCPSocket *) _Nullable _listeningSocket; +#ifdef OF_HAVE_THREADS + size_t _numberOfThreads, _nextThreadIndex; + OFArray *_threadPool; +#endif } /*! * @brief The host on which the HTTP server will listen. + * + * Setting this after @ref start has been called raises an + * @ref OFAlreadyConnectedException. */ @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *host; /*! * @brief The port on which the HTTP server will listen. + * + * Setting this after @ref start has been called raises an + * @ref OFAlreadyConnectedException. */ @property (nonatomic) uint16_t port; /*! * @brief Whether the HTTP server uses TLS. + * + * Setting this after @ref start has been called raises an + * @ref OFAlreadyConnectedException. */ @property (nonatomic) bool usesTLS; /*! * @brief The path to the X.509 certificate file to use for TLS. + * + * Setting this after @ref start has been called raises an + * @ref OFAlreadyConnectedException. */ @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *certificateFile; /*! * @brief The path to the PKCS#8 private key file to use for TLS. + * + * Setting this after @ref start has been called raises an + * @ref OFAlreadyConnectedException. */ @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *privateKeyFile; /*! * @brief The passphrase to decrypt the PKCS#8 private key file for TLS. * * @warning You have to ensure that this is in secure memory protected from * swapping! This is also the reason why this is not an OFString. + * + * Setting this after @ref start has been called raises an + * @ref OFAlreadyConnectedException. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) const char *privateKeyPassphrase; /*! * @brief The delegate for the HTTP server. */ @property OF_NULLABLE_PROPERTY (assign, nonatomic) id delegate; + +#ifdef OF_HAVE_THREADS +/*! + * @brief The number of threads the OFHTTPServer should use. + * + * If this is larger than 1 (the default), one thread will be used to accept + * incoming connections and all others will be used to handle connections. + * + * For maximum CPU utilization, set this to `[OFSystemInfo numberOfCPUs] + 1`. + * + * Setting this after @ref start has been called raises an + * @ref OFAlreadyConnectedException. + */ +@property (nonatomic) size_t numberOfThreads; +#endif /*! * @brief The server name the server presents to clients. * * Setting it to `nil` means no `Server` header will be sent, unless one is