log4cplus  2.0.6
connectorthread.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Copyright (C) 2013-2017, Vaclav Zeman. All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without modifica-
5 // tion, are permitted provided that the following conditions are met:
6 //
7 // 1. Redistributions of source code must retain the above copyright notice,
8 // this list of conditions and the following disclaimer.
9 //
10 // 2. Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
15 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
17 // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
19 // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
20 // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 #ifndef LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
26 #define LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
27 
28 #include <log4cplus/config.hxx>
29 
30 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
31 #pragma once
32 #endif
33 
37 
38 
39 #if ! defined (LOG4CPLUS_SINGLE_THREADED)
40 
41 namespace log4cplus { namespace helpers {
42 
43 
45 
48 {
49 protected:
50  virtual ~IConnectorThreadClient ();
51 
54  virtual thread::Mutex const & ctcGetAccessMutex () const = 0;
55 
57  virtual helpers::Socket & ctcGetSocket () = 0;
58 
61  virtual helpers::Socket ctcConnect () = 0;
62 
64  virtual void ctcSetConnected () = 0;
65 
67 };
68 
69 
73  : public thread::AbstractThread
74 {
75 public:
78  virtual ~ConnectorThread ();
79 
80  virtual void run();
81 
85  void terminate ();
86 
89  void trigger ();
90 
91 protected:
94 
97 
99  bool exit_flag;
100 };
101 
102 
103 } } // namespace log4cplus { namespace helpers {
104 
105 #endif // ! defined (LOG4CPLUS_SINGLE_THREADED)
106 
107 #endif // LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
log4cplus::helpers::Socket
This class implements client sockets (also called just "sockets").
Definition: helpers/socket.h:84
log4cplus
Definition: appender.h:46
log4cplus::thread::AbstractThread
There are many cross-platform C++ Threading libraries.
Definition: threads.h:75
threads.h
log4cplus::helpers::ConnectorThread::ctc
IConnectorThreadClient & ctc
reference to ConnectorThread's client
Definition: connectorthread.h:93
config.hxx
socket.h
log4cplus::thread::ManualResetEvent
Definition: syncprims.h:106
log4cplus::helpers::ConnectorThread
class LOG4CPLUS_EXPORT ConnectorThread
Definition: connectorthread.h:44
log4cplus::helpers::ConnectorThread
This class is used by SocketAppender and (remote) SysLogAppender to provide asynchronous re-connectio...
Definition: connectorthread.h:72
log4cplus::helpers::IConnectorThreadClient
Interface implemented by users of ConnectorThread.
Definition: connectorthread.h:47
LOG4CPLUS_EXPORT
#define LOG4CPLUS_EXPORT
Definition: win32.h:141
log4cplus::helpers::ConnectorThread::trigger_ev
thread::ManualResetEvent trigger_ev
This event is the re-connection trigger.
Definition: connectorthread.h:96
log4cplus::helpers::ConnectorThread::exit_flag
bool exit_flag
When this variable set to true when ConnectorThread is signaled to.
Definition: connectorthread.h:99
log4cplus::thread::Mutex
Definition: syncprims.h:63
syncprims.h