Skip to content

Commit 0ade907

Browse files
authored
Merge branch 'master' into fix_join_squashing
2 parents 3aea071 + 2439a68 commit 0ade907

File tree

77 files changed

+1020
-1020
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1020
-1020
lines changed

base/poco/Foundation/include/Poco/Message.h

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#define Foundation_Message_INCLUDED
1919

2020

21-
#include <map>
2221
#include <vector>
2322
#include "Poco/Foundation.h"
2423
#include "Poco/Timestamp.h"
@@ -67,11 +66,21 @@ class Foundation_API Message
6766
/// The thread and process ids are set.
6867

6968
Message(
70-
const std::string & source, const std::string & text, Priority prio, const char * file, int line,
71-
std::string_view fmt_str = {}, const std::vector<std::string> & fmt_str_args = {});
69+
const std::string & source,
70+
const std::string & text,
71+
Priority prio,
72+
std::string && file,
73+
int line,
74+
std::string_view fmt_str = {},
75+
const std::vector<std::string> & fmt_str_args = {});
7276
Message(
73-
std::string && source, std::string && text, Priority prio, const char * file, int line,
74-
std::string_view fmt_str, std::vector<std::string> && fmt_str_args);
77+
std::string && source,
78+
std::string && text,
79+
Priority prio,
80+
std::string && file,
81+
int line,
82+
std::string_view fmt_str,
83+
std::vector<std::string> && fmt_str_args);
7584
/// Creates a Message with the given source, text, priority,
7685
/// source file path and line.
7786
///
@@ -150,9 +159,9 @@ class Foundation_API Message
150159
/// the __FILE__ macro. The string is not copied
151160
/// internally for performance reasons.
152161

153-
const char * getSourceFile() const;
162+
const std::string & getSourceFile() const;
154163
/// Returns the source file path of the code creating
155-
/// the message. May be 0 if not set.
164+
/// the message. May be "" if not set.
156165

157166
void setSourceLine(int line);
158167
/// Sets the source file line of the statement
@@ -172,37 +181,8 @@ class Foundation_API Message
172181
/// generating the log message. May be 0
173182
/// if not set.
174183

175-
bool has(const std::string & param) const;
176-
/// Returns true if a parameter with the given name exists.
177-
178-
const std::string & get(const std::string & param) const;
179-
/// Returns a const reference to the value of the parameter
180-
/// with the given name. Throws a NotFoundException if the
181-
/// parameter does not exist.
182-
183-
const std::string & get(const std::string & param, const std::string & defaultValue) const;
184-
/// Returns a const reference to the value of the parameter
185-
/// with the given name. If the parameter with the given name
186-
/// does not exist, then defaultValue is returned.
187-
188-
void set(const std::string & param, const std::string & value);
189-
/// Sets the value for a parameter. If the parameter does
190-
/// not exist, then it is created.
191-
192-
const std::string & operator[](const std::string & param) const;
193-
/// Returns a const reference to the value of the parameter
194-
/// with the given name. Throws a NotFoundException if the
195-
/// parameter does not exist.
196-
197-
std::string & operator[](const std::string & param);
198-
/// Returns a reference to the value of the parameter with the
199-
/// given name. This can be used to set the parameter's value.
200-
/// If the parameter does not exist, it is created with an
201-
/// empty string value.
202-
203184
protected:
204185
void init();
205-
typedef std::map<std::string, std::string> StringMap;
206186

207187
private:
208188
std::string _source;
@@ -212,9 +192,8 @@ class Foundation_API Message
212192
long _tid;
213193
std::string _thread;
214194
mutable long _pid = -1;
215-
const char * _file;
195+
std::string _file;
216196
int _line;
217-
StringMap * _pMap;
218197
std::string_view _fmt_str;
219198
std::vector<std::string> _fmt_str_args;
220199
};
@@ -259,7 +238,7 @@ inline long Message::getTid() const
259238
}
260239

261240

262-
inline const char * Message::getSourceFile() const
241+
inline const std::string & Message::getSourceFile() const
263242
{
264243
return _file;
265244
}

base/poco/Foundation/include/Poco/NotificationQueue.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class Foundation_API NotificationQueue
5050
/// 4. destroy the notification queue.
5151
{
5252
public:
53+
using NfQueue = std::deque<Notification::Ptr>;
54+
5355
NotificationQueue();
5456
/// Creates the NotificationQueue.
5557

@@ -124,6 +126,8 @@ class Foundation_API NotificationQueue
124126
void clear();
125127
/// Removes all notifications from the queue.
126128

129+
NfQueue getCurrentQueueAndClear();
130+
127131
bool hasIdleThreads() const;
128132
/// Returns true if the queue has at least one thread waiting
129133
/// for a notification.
@@ -136,7 +140,6 @@ class Foundation_API NotificationQueue
136140
Notification::Ptr dequeueOne();
137141

138142
private:
139-
typedef std::deque<Notification::Ptr> NfQueue;
140143
struct WaitInfo
141144
{
142145
Notification::Ptr pNf;

base/poco/Foundation/include/Poco/Thread_POSIX.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class Foundation_API ThreadImpl
124124
std::size_t stackSize;
125125
bool started;
126126
bool joined;
127+
mutable FastMutex mutex;
127128
};
128129

129130
AutoPtr<ThreadData> _pData;
@@ -154,6 +155,7 @@ inline int ThreadImpl::getOSPriorityImpl() const
154155

155156
inline bool ThreadImpl::isRunningImpl() const
156157
{
158+
FastMutex::ScopedLock l(_pData->mutex);
157159
return !_pData->pRunnableTarget.isNull();
158160
}
159161

base/poco/Foundation/src/Message.cpp

Lines changed: 41 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
#include "Poco/Message.h"
16-
#include "Poco/Exception.h"
1716
#include "Poco/Process.h"
1817
#include "Poco/Thread.h"
1918
#include <algorithm>
@@ -22,59 +21,63 @@
2221
namespace Poco {
2322

2423

25-
Message::Message():
26-
_prio(PRIO_FATAL),
27-
_tid(0),
28-
_file(0),
29-
_line(0),
30-
_pMap(0)
24+
Message::Message()
25+
: _prio(PRIO_FATAL)
26+
, _tid(0)
27+
, _line(0)
3128
{
3229
init();
3330
}
3431

3532

36-
Message::Message(const std::string& source, const std::string& text, Priority prio):
37-
_source(source),
38-
_text(text),
39-
_prio(prio),
40-
_tid(0),
41-
_file(0),
42-
_line(0),
43-
_pMap(0)
33+
Message::Message(const std::string & source, const std::string & text, Priority prio)
34+
: _source(source)
35+
, _text(text)
36+
, _prio(prio)
37+
, _tid(0)
38+
, _line(0)
4439
{
4540
init();
4641
}
4742

4843

4944
Message::Message(
50-
const std::string& source, const std::string& text, Priority prio, const char* file, int line,
51-
std::string_view fmt_str, const std::vector<std::string>& fmt_str_args):
52-
_source(source),
53-
_text(text),
54-
_prio(prio),
55-
_tid(0),
56-
_file(file),
57-
_line(line),
58-
_pMap(0),
59-
_fmt_str(fmt_str),
60-
_fmt_str_args(fmt_str_args)
45+
const std::string & source,
46+
const std::string & text,
47+
Priority prio,
48+
std::string && file,
49+
int line,
50+
std::string_view fmt_str,
51+
const std::vector<std::string> & fmt_str_args)
52+
: _source(source)
53+
, _text(text)
54+
, _prio(prio)
55+
, _tid(0)
56+
, _file(file)
57+
, _line(line)
58+
, _fmt_str(fmt_str)
59+
, _fmt_str_args(fmt_str_args)
6160
{
6261
init();
6362
}
6463

6564

6665
Message::Message(
67-
std::string && source, std::string && text, Priority prio, const char * file, int line,
68-
std::string_view fmt_str, std::vector<std::string> && fmt_str_args):
69-
_source(std::move(source)),
70-
_text(std::move(text)),
71-
_prio(prio),
72-
_tid(0),
73-
_file(file),
74-
_line(line),
75-
_pMap(0),
76-
_fmt_str(fmt_str),
77-
_fmt_str_args(std::move(fmt_str_args))
66+
std::string && source,
67+
std::string && text,
68+
Priority prio,
69+
std::string && file,
70+
int line,
71+
std::string_view fmt_str,
72+
std::vector<std::string> && fmt_str_args)
73+
: _source(std::move(source))
74+
, _text(std::move(text))
75+
, _prio(prio)
76+
, _tid(0)
77+
, _file(file)
78+
, _line(line)
79+
, _fmt_str(fmt_str)
80+
, _fmt_str_args(std::move(fmt_str_args))
7881
{
7982
init();
8083
}
@@ -92,10 +95,6 @@ Message::Message(const Message& msg):
9295
_fmt_str(msg._fmt_str),
9396
_fmt_str_args(msg._fmt_str_args)
9497
{
95-
if (msg._pMap)
96-
_pMap = new StringMap(*msg._pMap);
97-
else
98-
_pMap = 0;
9998
}
10099

101100

@@ -112,17 +111,10 @@ Message::Message(const Message& msg, const std::string& text):
112111
_fmt_str(msg._fmt_str),
113112
_fmt_str_args(msg._fmt_str_args)
114113
{
115-
if (msg._pMap)
116-
_pMap = new StringMap(*msg._pMap);
117-
else
118-
_pMap = 0;
119114
}
120115

121116

122-
Message::~Message()
123-
{
124-
delete _pMap;
125-
}
117+
Message::~Message() = default;
126118

127119

128120
void Message::init()
@@ -160,7 +152,6 @@ void Message::swap(Message& msg)
160152
swap(_pid, msg._pid);
161153
swap(_file, msg._file);
162154
swap(_line, msg._line);
163-
swap(_pMap, msg._pMap);
164155
swap(_fmt_str, msg._fmt_str);
165156
swap(_fmt_str_args, msg._fmt_str_args);
166157
}
@@ -246,39 +237,6 @@ void Message::setFormatStringArgs(const std::vector<std::string>& fmt_str_args)
246237
_fmt_str_args = fmt_str_args;
247238
}
248239

249-
250-
bool Message::has(const std::string& param) const
251-
{
252-
return _pMap && (_pMap->find(param) != _pMap->end());
253-
}
254-
255-
256-
const std::string& Message::get(const std::string& param) const
257-
{
258-
if (_pMap)
259-
{
260-
StringMap::const_iterator it = _pMap->find(param);
261-
if (it != _pMap->end())
262-
return it->second;
263-
}
264-
265-
throw NotFoundException();
266-
}
267-
268-
269-
const std::string& Message::get(const std::string& param, const std::string& defaultValue) const
270-
{
271-
if (_pMap)
272-
{
273-
StringMap::const_iterator it = _pMap->find(param);
274-
if (it != _pMap->end())
275-
return it->second;
276-
}
277-
278-
return defaultValue;
279-
}
280-
281-
282240
long Message::getPid() const
283241
{
284242
if (_pid < 0)
@@ -287,35 +245,4 @@ long Message::getPid() const
287245
}
288246

289247

290-
void Message::set(const std::string& param, const std::string& value)
291-
{
292-
if (!_pMap)
293-
_pMap = new StringMap;
294-
295-
std::pair<StringMap::iterator, bool> result =
296-
_pMap->insert(std::make_pair(param, value));
297-
if (!result.second)
298-
{
299-
result.first->second = value;
300-
}
301-
}
302-
303-
304-
const std::string& Message::operator [] (const std::string& param) const
305-
{
306-
if (_pMap)
307-
return (*_pMap)[param];
308-
else
309-
throw NotFoundException();
310-
}
311-
312-
313-
std::string& Message::operator [] (const std::string& param)
314-
{
315-
if (!_pMap)
316-
_pMap = new StringMap;
317-
return (*_pMap)[param];
318-
}
319-
320-
321248
} // namespace Poco

base/poco/Foundation/src/NotificationQueue.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ void NotificationQueue::clear()
176176
_nfQueue.clear();
177177
}
178178

179+
NotificationQueue::NfQueue NotificationQueue::getCurrentQueueAndClear()
180+
{
181+
FastMutex::ScopedLock lock(_mutex);
182+
NfQueue nf;
183+
std::swap(_nfQueue, nf);
184+
return nf;
185+
}
179186

180187
bool NotificationQueue::hasIdleThreads() const
181188
{

0 commit comments

Comments
 (0)