libnative-utilities/include/raknet/ThreadsafePacketLogger.hpp
2024-08-15 18:40:30 +08:00

49 lines
1.1 KiB
C++

/*
* Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
/// \file
/// \brief Derivation of the packet logger to defer the call to WriteLog until the user thread.
///
#include "NativeFeatureIncludes.hpp"
#if _RAKNET_SUPPORT_PacketLogger==1
#ifndef __THREADSAFE_PACKET_LOGGER_H
#define __THREADSAFE_PACKET_LOGGER_H
#include "PacketLogger.hpp"
#include "SingleProducerConsumer.hpp"
namespace RakNet
{
/// \ingroup PACKETLOGGER_GROUP
/// \brief Same as PacketLogger, but writes output in the user thread.
class RAK_DLL_EXPORT ThreadsafePacketLogger : public PacketLogger
{
public:
ThreadsafePacketLogger();
virtual ~ThreadsafePacketLogger();
virtual void Update(void);
protected:
virtual void AddToLog(const char *str);
DataStructures::SingleProducerConsumer<char*> logMessages;
};
} // namespace RakNet
#endif
#endif // _RAKNET_SUPPORT_*