~ubuntu-branches/ubuntu/quantal/poco/quantal

« back to all changes in this revision

Viewing changes to Foundation/include/Poco/ThreadPool.h

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Burghardt
  • Date: 2008-11-15 11:39:15 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081115113915-7kauhm2c3m2i7oid
Tags: 1.3.3p1-2
* Fixed FTBFS with GCC 4.4 due to missing #include (Closes: #505619)
* Renamed 20_gcc43-missing-include.dpatch to 20_gcc44-missing-include.dpatch
* Downgraded dependencies on -dbg packages (Closes: #504342)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
2
// ThreadPool.h
3
3
//
4
 
// $Id: //poco/1.3/Foundation/include/Poco/ThreadPool.h#1 $
 
4
// $Id: //poco/1.3/Foundation/include/Poco/ThreadPool.h#3 $
5
5
//
6
6
// Library: Foundation
7
7
// Package: Threading
69
69
        /// from the pool.
70
70
{
71
71
public:
72
 
        ThreadPool(int minCapacity = 2, int maxCapacity = 16, int idleTime = 60);
73
 
        ThreadPool(const std::string& name, int minCapacity = 2, int maxCapacity = 16, int idleTime = 60);
 
72
        ThreadPool(int minCapacity = 2,
 
73
                int maxCapacity = 16,
 
74
                int idleTime = 60,
 
75
                int stackSize = POCO_THREAD_STACK_SIZE);
 
76
        ThreadPool(const std::string& name,
 
77
                int minCapacity = 2,
 
78
                int maxCapacity = 16,
 
79
                int idleTime = 60,
 
80
                int stackSize = POCO_THREAD_STACK_SIZE);
74
81
                /// Creates a thread pool with minCapacity threads.
75
82
                /// If required, up to maxCapacity threads are created
76
83
                /// a NoThreadAvailableException exception is thrown.
77
84
                /// If a thread is running idle for more than idleTime seconds,
78
85
                /// and more than minCapacity threads are running, the thread
79
 
                /// is killed.
 
86
                /// is killed. Threads are created with given stack size.
80
87
 
81
88
        ~ThreadPool();
82
89
                /// Currently running threads will remain active
89
96
        int capacity() const;
90
97
                /// Returns the maximum capacity of threads.
91
98
 
 
99
        void setStackSize(int stackSize);
 
100
                /// Sets the stack size for threads.
 
101
                /// New stack size applies only for newly created threads.
 
102
 
 
103
        int getStackSize() const;
 
104
                /// Returns the stack size used to create new threads.
 
105
 
92
106
        int used() const;
93
107
                /// Returns the number of currently used threads.
94
108
 
159
173
        int _idleTime;
160
174
        int _serial;
161
175
        int _age;
 
176
        int _stackSize;
162
177
        ThreadVec _threads;
163
178
        mutable FastMutex _mutex;
164
179
};
165
180
 
166
181
 
 
182
//
 
183
// inlines
 
184
//
 
185
inline void ThreadPool::setStackSize(int stackSize)
 
186
{
 
187
        _stackSize = stackSize;
 
188
}
 
189
 
 
190
 
 
191
inline int ThreadPool::getStackSize() const
 
192
{
 
193
        return _stackSize;
 
194
}
 
195
 
 
196
 
167
197
} // namespace Poco
168
198
 
169
199