log4cplus 2.0.8
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
41namespace log4cplus { namespace helpers {
42
43
45
48{
49protected:
51
54 virtual thread::Mutex const & ctcGetAccessMutex () const = 0;
55
57 virtual helpers::Socket & ctcGetSocket () = 0;
58
62
64 virtual void ctcSetConnected () = 0;
65
67};
68
69
74{
75public:
78 virtual ~ConnectorThread ();
79
80 virtual void run();
81
85 void terminate ();
86
89 void trigger ();
90
91protected:
94
97
100};
101
102
103} } // namespace log4cplus { namespace helpers {
104
105#endif // ! defined (LOG4CPLUS_SINGLE_THREADED)
106
107#endif // LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
This class is used by SocketAppender and (remote) SysLogAppender to provide asynchronous re-connectio...
IConnectorThreadClient & ctc
reference to ConnectorThread's client
ConnectorThread(IConnectorThreadClient &client)
void terminate()
Call this function to terminate ConnectorThread.
thread::ManualResetEvent trigger_ev
This event is the re-connection trigger.
void trigger()
This function triggers (trigger_ev) connection check and attempt to re-connect a broken connection,...
bool exit_flag
When this variable set to true when ConnectorThread is signaled to.
Interface implemented by users of ConnectorThread.
virtual helpers::Socket ctcConnect()=0
virtual thread::Mutex const & ctcGetAccessMutex() const =0
virtual void ctcSetConnected()=0
Sets connected flag to true in ConnectorThread's client.
virtual helpers::Socket & ctcGetSocket()=0
This class implements client sockets (also called just "sockets").
There are many cross-platform C++ Threading libraries.
Definition: threads.h:77
#define LOG4CPLUS_EXPORT
Definition: win32.h:141