Skip to content

Commit

Permalink
Move Predicate.h from Host to Utility
Browse files Browse the repository at this point in the history
Summary:
This class was initially in Host because its implementation used to be
very OS-specific. However, with C++11, it has become a very simple
std::condition_variable wrapper, with no host-specific code.

It is also a general purpose utility class, so it makes sense for it to
live in a place where it can be used by everyone.

This has no effect on the layering right now, but it enables me to later
move the Listener+Broadcaster+Event combo to a lower layer, which is
important, as these are used in a lot of places (notably for launching a
process in Host code).

Reviewers: jingham, zturner, teemperor

Reviewed By: zturner

Subscribers: xiaobai, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D50384

llvm-svn: 341089
  • Loading branch information
Teemperor committed Aug 30, 2018
1 parent b7e1433 commit 7fae493
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lldb/include/lldb/Core/Event.h
Expand Up @@ -11,8 +11,8 @@
#define liblldb_Event_h_

#include "lldb/Core/Broadcaster.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
#include "lldb/lldb-forward.h" // for EventDataSP, ProcessSP, Struct...
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Core/IOHandler.h
Expand Up @@ -11,9 +11,9 @@
#define liblldb_IOHandler_h_

#include "lldb/Core/ValueObjectList.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Flags.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StringList.h"
#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Host/Editline.h
Expand Up @@ -54,8 +54,8 @@
#include <vector>

#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Predicate.h"

namespace lldb_private {
namespace line_editor {
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Host/Socket.h
Expand Up @@ -15,9 +15,9 @@

#include "lldb/lldb-private.h"

#include "lldb/Host/Predicate.h"
#include "lldb/Host/SocketAddress.h"
#include "lldb/Utility/IOObject.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/Utility/Status.h"

#ifdef _WIN32
Expand Down
Expand Up @@ -20,9 +20,9 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Host/Pipe.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Utility/Connection.h"
#include "lldb/Utility/IOObject.h"
#include "lldb/Utility/Predicate.h"

namespace lldb_private {

Expand Down
Expand Up @@ -34,11 +34,11 @@ typedef enum {
eBroadcastNever, ///< No broadcast will be sent when the value is modified.
eBroadcastAlways, ///< Always send a broadcast when the value is modified.
eBroadcastOnChange ///< Only broadcast if the value changes when the value is
///modified.
/// modified.
} PredicateBroadcastType;

//----------------------------------------------------------------------
/// @class Predicate Predicate.h "lldb/Host/Predicate.h"
/// @class Predicate Predicate.h "lldb/Utility/Predicate.h"
/// A C++ wrapper class for providing threaded access to a value of
/// type T.
///
Expand Down Expand Up @@ -220,8 +220,8 @@ template <class T> class Predicate {
T m_value; ///< The templatized value T that we are protecting access to
mutable std::mutex m_mutex; ///< The mutex to use when accessing the data
std::condition_variable m_condition; ///< The pthread condition variable to
///use for signaling that data available
///or changed.
/// use for signaling that data available
/// or changed.

private:
//------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion lldb/include/lldb/module.modulemap
Expand Up @@ -38,7 +38,6 @@ module lldb_Host {
module PipeBase { header "Host/PipeBase.h" export * }
module Pipe { header "Host/Pipe.h" export * }
module PosixApi { header "Host/PosixApi.h" export * }
module Predicate { header "Host/Predicate.h" export * }
module ProcessLauncher { header "Host/ProcessLauncher.h" export * }
module ProcessRunLock { header "Host/ProcessRunLock.h" export * }
module PseudoTerminal { header "Host/PseudoTerminal.h" export * }
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/IOHandler.cpp
Expand Up @@ -26,7 +26,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/File.h" // for File
#include "lldb/Host/Predicate.h" // for Predicate, ::eBroad...
#include "lldb/Utility/Predicate.h" // for Predicate, ::eBroad...
#include "lldb/Utility/Status.h" // for Status
#include "lldb/Utility/StreamString.h" // for StreamString
#include "lldb/Utility/StringList.h" // for StringList
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Host/common/Host.cpp
Expand Up @@ -52,7 +52,6 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostProcess.h"
#include "lldb/Host/MonitoringProcessLauncher.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/ProcessLauncher.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
Expand All @@ -62,6 +61,7 @@
#include "lldb/Utility/DataBufferLLVM.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/Utility/Status.h"
#include "lldb/lldb-private-forward.h"
#include "llvm/ADT/SmallString.h"
Expand Down
Expand Up @@ -21,7 +21,7 @@
#include "lldb/Core/Communication.h"
#include "lldb/Core/Listener.h"
#include "lldb/Core/StreamBuffer.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/lldb-private.h"

class CommunicationKDP : public lldb_private::Communication {
Expand Down
Expand Up @@ -12,7 +12,6 @@
#include "IDebugDelegate.h"

#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/windows/HostProcessWindows.h"
#include "lldb/Host/windows/HostThreadWindows.h"
Expand All @@ -21,6 +20,7 @@
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/Utility/Status.h"

#include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
Expand Down
Expand Up @@ -16,8 +16,8 @@
#include "ForwardDecl.h"
#include "lldb/Host/HostProcess.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/windows/windows.h"
#include "lldb/Utility/Predicate.h"

namespace lldb_private {

Expand Down
Expand Up @@ -23,8 +23,8 @@
#include "lldb/Core/Communication.h"
#include "lldb/Core/Listener.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/lldb-public.h"

#include "lldb/Utility/StringExtractorGDBRemote.h"
Expand Down
2 changes: 1 addition & 1 deletion lldb/unittests/Core/BroadcasterTest.cpp
Expand Up @@ -12,7 +12,7 @@
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Event.h"
#include "lldb/Core/Listener.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Utility/Predicate.h"

#include <thread>

Expand Down
1 change: 0 additions & 1 deletion lldb/unittests/Host/CMakeLists.txt
Expand Up @@ -3,7 +3,6 @@ set (FILES
HostInfoTest.cpp
HostTest.cpp
MainLoopTest.cpp
PredicateTest.cpp
SocketAddressTest.cpp
SocketTest.cpp
SymbolsTest.cpp
Expand Down
1 change: 1 addition & 0 deletions lldb/unittests/Utility/CMakeLists.txt
Expand Up @@ -12,6 +12,7 @@ add_lldb_unittest(UtilityTests
JSONTest.cpp
LogTest.cpp
NameMatchesTest.cpp
PredicateTest.cpp
RegisterValueTest.cpp
ScalarTest.cpp
StateTest.cpp
Expand Down
Expand Up @@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//

#include "lldb/Host/Predicate.h"
#include "lldb/Utility/Predicate.h"
#include "gtest/gtest.h"
#include <thread>

Expand Down

0 comments on commit 7fae493

Please sign in to comment.