connectorthread.h
Go to the documentation of this file.
// -*- C++ -*-
// Copyright (C) 2013-2017, Vaclav Zeman. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modifica-
// tion, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
#define LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
#include <log4cplus/config.hxx>
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
#pragma once
#endif
#include <log4cplus/thread/syncprims.h>
#include <log4cplus/thread/threads.h>
#include <log4cplus/helpers/socket.h>
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
namespace log4cplus { namespace helpers {
class LOG4CPLUS_EXPORT ConnectorThread;
class LOG4CPLUS_EXPORT IConnectorThreadClient
{
protected:
virtual ~IConnectorThreadClient ();
virtual thread::Mutex const & ctcGetAccessMutex () const = 0;
virtual helpers::Socket & ctcGetSocket () = 0;
virtual helpers::Socket ctcConnect () = 0;
virtual void ctcSetConnected () = 0;
friend class LOG4CPLUS_EXPORT ConnectorThread;
};
class LOG4CPLUS_EXPORT ConnectorThread
: public thread::AbstractThread
{
public:
ConnectorThread (IConnectorThreadClient & client);
virtual ~ConnectorThread ();
virtual void run();
void terminate ();
void trigger ();
protected:
IConnectorThreadClient & ctc;
thread::ManualResetEvent trigger_ev;
bool exit_flag;
};
} } // namespace log4cplus { namespace helpers {
#endif // ! defined (LOG4CPLUS_SINGLE_THREADED)
#endif // LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
log4cplus::helpers::ConnectorThread
Definition connectorthread.h:74
log4cplus::helpers::ConnectorThread::run
virtual void run()
log4cplus::helpers::ConnectorThread::ctc
IConnectorThreadClient & ctc
reference to ConnectorThread's client
Definition connectorthread.h:93
log4cplus::helpers::ConnectorThread::ConnectorThread
ConnectorThread(IConnectorThreadClient &client)
log4cplus::helpers::ConnectorThread::terminate
void terminate()
log4cplus::helpers::ConnectorThread::trigger_ev
thread::ManualResetEvent trigger_ev
This event is the re-connection trigger.
Definition connectorthread.h:96
log4cplus::helpers::ConnectorThread::trigger
void trigger()
log4cplus::helpers::ConnectorThread::~ConnectorThread
virtual ~ConnectorThread()
log4cplus::helpers::ConnectorThread::exit_flag
bool exit_flag
When this variable set to true when ConnectorThread is signaled to.
Definition connectorthread.h:99
log4cplus::helpers::IConnectorThreadClient
Interface implemented by users of ConnectorThread.
Definition connectorthread.h:48
log4cplus::helpers::IConnectorThreadClient::ConnectorThread
friend class LOG4CPLUS_EXPORT ConnectorThread
Definition connectorthread.h:66
log4cplus::helpers::IConnectorThreadClient::ctcConnect
virtual helpers::Socket ctcConnect()=0
log4cplus::helpers::IConnectorThreadClient::~IConnectorThreadClient
virtual ~IConnectorThreadClient()
log4cplus::helpers::IConnectorThreadClient::ctcGetAccessMutex
virtual thread::Mutex const & ctcGetAccessMutex() const =0
log4cplus::helpers::IConnectorThreadClient::ctcSetConnected
virtual void ctcSetConnected()=0
Sets connected flag to true in ConnectorThread's client.
log4cplus::helpers::IConnectorThreadClient::ctcGetSocket
virtual helpers::Socket & ctcGetSocket()=0
log4cplus::helpers::Socket
This class implements client sockets (also called just "sockets").
Definition helpers/socket.h:84
log4cplus::thread::AbstractThread
There are many cross-platform C++ Threading libraries.
Definition threads.h:77
log4cplus::thread::ManualResetEvent
Definition syncprims.h:126
log4cplus::thread::Mutex
Definition syncprims.h:83
config.hxx
socket.h
log4cplus::helpers
Definition appender.h:50
log4cplus
Definition appender.h:46
syncprims.h
threads.h
LOG4CPLUS_EXPORT
#define LOG4CPLUS_EXPORT
Definition win32.h:141