Wt  4.10.4
Public Member Functions | List of all members
Wt::WIOService Class Reference

An I/O service. More...

Inherits AsioWrapper::asio::io_service.

Public Member Functions

 WIOService ()
 Creates a new IO service. More...
void setThreadCount (int number)
 Configures the number of threads. More...
int threadCount () const
 Returns the thread count.
void start ()
 Starts the I/O service. More...
void stop ()
 Stops the I/O service. More...
void post (const std::function< void()> &function)
 Posts a function into the thread-pool. More...
void schedule (std::chrono::steady_clock::duration millis, const std::function< void()> &function)
 Schedules a function on the thread-pool. More...
virtual void initializeThread ()
 Initializes a thread. More...

Detailed Description

An I/O service.


An I/O service combines (boost::)asio::io_service with a thread pool.

Constructor & Destructor Documentation

◆ WIOService()

Wt::WIOService::WIOService ( )

Creates a new IO service.

See also

Member Function Documentation

◆ initializeThread()

void Wt::WIOService::initializeThread ( )

Initializes a thread.

This function is called for every new thread created, and can be used to configure the thread, e.g. with respect to scheduling priorities.

◆ post()

void Wt::WIOService::post ( const std::function< void()> &  function)

Posts a function into the thread-pool.

The function will be executed within a thread of the thread-pool.

This method returns immediately.

◆ schedule()

void Wt::WIOService::schedule ( std::chrono::steady_clock::duration  millis,
const std::function< void()> &  function 

Schedules a function on the thread-pool.

The function will be executed after a time out, specified in milli-seconds, on the thread pool.

◆ setThreadCount()

void Wt::WIOService::setThreadCount ( int  number)

Configures the number of threads.

This must be configured before the server is started using start().

The default thread count is 5 (or is configured by WServer from information in the configuration file).

◆ start()

void Wt::WIOService::start ( )

Starts the I/O service.

This will start the internal thread pool to process work for the I/O service, if not already started.

◆ stop()

void Wt::WIOService::stop ( )

Stops the I/O service.

This will stop the internal thread pool. The method will block until all work has been completed.