This file is indexed.

/usr/include/Wt/WIOService is in libwt-dev 3.3.0-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2011 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WCORE_SERVER_H_
#define WCORE_SERVER_H_

#include <boost/asio/io_service.hpp>
#include <boost/asio/deadline_timer.hpp>
#ifdef WT_THREADED
#include <boost/thread.hpp>
#endif
#include <boost/function.hpp>

namespace boost {
  class thread;
}

#include <Wt/WDllDefs.h>

namespace Wt {

/**! \class WIOService Wt/WIOService Wt/WIOService
 *   \brief An I/O service.
 *
 * An I/O service combines a boost::asio::io_service with a thread pool.
 */
class WT_API WIOService : public boost::asio::io_service
{
public:
  /*! \brief Creates a new IO service.
   *
   * \sa setServerConfiguration()
   */
  WIOService();
  virtual ~WIOService();

  /*! \brief Configures the number of threads.
   *
   * This must be configured before the server is started using start().
   *
   * The default thread count is 10 (or is configured by WServer from
   * information in the configuration file).
   */
  void setThreadCount(int number);

  /*! \brief Returns the thread count.
   */
  int threadCount() const;

  /*! \brief Starts the I/O service.
   *
   * This will start the internal thread pool to process work for
   * the I/O service, if not already started.
   */
  void start();

  /*! \brief Stops the I/O service.
   *
   * This will stop the internal thread pool. The method will block until
   * all work has been completed.
   */
  void stop();

  /*! \brief Posts a function into the thread-pool.
   *
   * The function will be executed within a thread of the thread-pool.
   *
   * This method returns immediately.
   */
  void post(const boost::function<void ()>& function);

  /*! \brief Schedules a function on the thread-pool.
   *
   * The function will be executed after a time out, specified in
   * milli-seconds, on the thread pool.
   */
  void schedule(int milliSeconds, const boost::function<void()>& function);

  /*! \brief 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.
   */
  virtual void initializeThread();

  // returns false if blocking an extra thread would block the last thread
  // if true is returned, a counter that keeps track of the amount of threads
  // doing blocking operations is incremented
  // Typical use case example: recursive event loop
  bool requestBlockedThread();

  // decrement the blocked thread counter
  void releaseBlockedThread();

private:
  int threadCount_;
  boost::asio::io_service::work *work_;

#ifdef WT_THREADED
  boost::mutex blockedThreadMutex_;
  int blockedThreadCounter_;
#endif

  std::vector<boost::thread *> threads_;

  void handleTimeout(boost::asio::deadline_timer *timer,
		     const boost::function<void ()>& function,
		     const boost::system::error_code& e);
  void run();
};

}

#endif // WCORE_SERVER_H_