+78
-8
lines changedFilter options
+78
-8
lines changed Original file line number Diff line number Diff line change
@@ -47,6 +47,21 @@ LOG4CPLUS_EXPORT void setCurrentThreadName2(const log4cplus::tstring & name);
47
47
LOG4CPLUS_EXPORT void yield();
48
48
LOG4CPLUS_EXPORT void blockAllSignals();
49
49
50
+
/**
51
+
* This class blocks all POSIX signals when created and unblocks them when
52
+
* destroyed.
53
+
*/
54
+
class LOG4CPLUS_EXPORT SignalsBlocker
55
+
{
56
+
public:
57
+
SignalsBlocker();
58
+
~SignalsBlocker();
59
+
60
+
private:
61
+
struct SignalsBlockerImpl;
62
+
std::unique_ptr<SignalsBlockerImpl> impl;
63
+
};
64
+
50
65
51
66
#ifndef LOG4CPLUS_SINGLE_THREADED
52
67
Original file line number Diff line number Diff line change
@@ -131,6 +131,17 @@ Initializer::~Initializer ()
131
131
namespace
132
132
{
133
133
134
+
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
135
+
static
136
+
std::unique_ptr<progschj::ThreadPool>
137
+
instantiate_thread_pool ()
138
+
{
139
+
log4cplus::thread::SignalsBlocker sb;
140
+
return std::unique_ptr<progschj::ThreadPool>(new progschj::ThreadPool);
141
+
}
142
+
#endif
143
+
144
+
134
145
//! Default context.
135
146
struct DefaultContext
136
147
{
@@ -146,7 +157,7 @@ struct DefaultContext
146
157
spi::FilterFactoryRegistry filter_factory_registry;
147
158
spi::LocaleFactoryRegistry locale_factory_registry;
148
159
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
149
-
std::unique_ptr<progschj::ThreadPool> thread_pool {new progschj::ThreadPool};
160
+
std::unique_ptr<progschj::ThreadPool> thread_pool {instantiate_thread_pool ()};
150
161
#endif
151
162
Hierarchy hierarchy;
152
163
};
@@ -562,7 +573,7 @@ threadCleanup ()
562
573
563
574
564
575
void
565
-
setThreadPoolSize (std::size_t pool_size)
576
+
setThreadPoolSize (std::size_t LOG4CPLUS_THREADED (pool_size))
566
577
{
567
578
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
568
579
get_dc ()->thread_pool->set_pool_size (pool_size);
Original file line number Diff line number Diff line change
@@ -53,9 +53,10 @@
53
53
#include <log4cplus/internal/cygwin-win32.h>
54
54
#include <log4cplus/streams.h>
55
55
56
+
#include <log4cplus/thread/threads.h>
57
+
56
58
#ifndef LOG4CPLUS_SINGLE_THREADED
57
59
58
-
#include <log4cplus/thread/threads.h>
59
60
#include <log4cplus/thread/impl/threads-impl.h>
60
61
#include <log4cplus/thread/impl/tls.h>
61
62
#include <log4cplus/ndc.h>
@@ -202,6 +203,37 @@ LOG4CPLUS_EXPORT void setCurrentThreadName2(const log4cplus::tstring & name)
202
203
}
203
204
204
205
206
+
//
207
+
//
208
+
//
209
+
210
+
struct SignalsBlocker::SignalsBlockerImpl
211
+
{
212
+
#if defined (LOG4CPLUS_USE_PTHREADS)
213
+
sigset_t signal_set;
214
+
#endif
215
+
};
216
+
217
+
218
+
SignalsBlocker::SignalsBlocker ()
219
+
: impl (new SignalsBlocker::SignalsBlockerImpl)
220
+
{
221
+
#if defined (LOG4CPLUS_USE_PTHREADS)
222
+
sigset_t block_all_set;
223
+
sigfillset (&block_all_set);
224
+
(void) pthread_sigmask (SIG_BLOCK, &block_all_set, &impl->signal_set);
225
+
#endif
226
+
}
227
+
228
+
229
+
SignalsBlocker::~SignalsBlocker()
230
+
{
231
+
#if defined (LOG4CPLUS_USE_PTHREADS)
232
+
(void) pthread_sigmask (SIG_BLOCK, &impl->signal_set, nullptr);
233
+
#endif
234
+
}
235
+
236
+
205
237
#ifndef LOG4CPLUS_SINGLE_THREADED
206
238
207
239
//
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
1
1
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
2
-
//
2
+
//
3
3
// Redistribution and use in source and binary forms, with or without modifica-
4
4
// tion, are permitted provided that the following conditions are met:
5
-
//
5
+
//
6
6
// 1. Redistributions of source code must retain the above copyright notice,
7
7
// this list of conditions and the following disclaimer.
8
-
//
8
+
//
9
9
// 2. Redistributions in binary form must reproduce the above copyright notice,
10
10
// this list of conditions and the following disclaimer in the documentation
11
11
// and/or other materials provided with the distribution.
12
-
//
12
+
//
13
13
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
14
14
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
15
15
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -34,4 +34,16 @@ namespace log4cplus
34
34
unsigned const version = LOG4CPLUS_VERSION;
35
35
char const versionStr[] = LOG4CPLUS_VERSION_STR LOG4CPLUS_VERSION_STR_SUFFIX;
36
36
37
-
}
37
+
namespace
38
+
{
39
+
40
+
#if defined (__ELF__) && (defined (__GNUC__) || defined (__clang__))
41
+
char const versionStrComment[]
42
+
__attribute__ ((__used__, __section__ ((".comment"))))
43
+
= "log4cplus " LOG4CPLUS_VERSION_STR LOG4CPLUS_VERSION_STR_SUFFIX;
44
+
#endif
45
+
46
+
47
+
} // namespace
48
+
49
+
} // namespace log4cplus
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4