Browse Source

merge. update cmake.

cl-refactor
subtly 11 years ago
parent
commit
60d2b970f5
  1. 2
      alethzero/CMakeLists.txt
  2. 5
      libethereum/CMakeLists.txt
  3. 9
      libethereum/Client.cpp
  4. 4
      libethereum/Client.h
  5. 5
      libethereum/Common.cpp
  6. 24
      libethereum/Common.h

2
alethzero/CMakeLists.txt

@ -29,7 +29,7 @@ qt5_wrap_ui(ui_Main.h Main.ui)
# Set name of binary and add_executable()
if (APPLE)
set(EXECUTEABLE AlethZero)
# set(CMAKE_INSTALL_PREFIX ./)
set(CMAKE_INSTALL_PREFIX ./)
set(BIN_INSTALL_DIR ".")
set(DOC_INSTALL_DIR ".")

5
libethereum/CMakeLists.txt

@ -33,8 +33,9 @@ if(${TARGET_PLATFORM} STREQUAL "w64")
target_link_libraries(ethereum shlwapi)
else ()
target_link_libraries(ethereum ${CRYPTOPP_LIBRARIES})
target_link_libraries(ethereum boost_system)
target_link_libraries(ethereum boost_filesystem)
target_link_libraries(ethereum boost_system-mt)
target_link_libraries(ethereum boost_filesystem-mt)
target_link_libraries(ethereum boost_thread-mt)
find_package(Threads REQUIRED)
target_link_libraries(ethereum ${CMAKE_THREAD_LIBS_INIT})
endif ()

9
libethereum/Client.cpp

@ -46,17 +46,8 @@ Client::Client(std::string const& _clientVersion, Address _us, std::string const
static const char* c_threadName = "eth";
#if defined(__APPLE__)
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
m_work = dispatch_queue_create(c_threadName, DISPATCH_QUEUE_SERIAL);
});
dispatch_async(m_work, ^{
#else
m_work = new thread([&](){
setThreadName(c_threadName);
#endif
while (m_workState != Deleting) work(); m_workState = Deleted;
});

4
libethereum/Client.h

@ -138,11 +138,7 @@ private:
State m_mined; ///< The state of the client which we're mining (i.e. it'll have all the rewards added).
PeerServer* m_net = nullptr; ///< Should run in background and send us events when blocks found and allow us to send blocks as required.
#if defined(__APPLE__)
dispatch_queue_t m_work;
#else
std::thread* m_work; ///< The work thread.
#endif
std::mutex m_lock;
enum { Active = 0, Deleting, Deleted } m_workState = Active;

5
libethereum/Common.cpp

@ -44,10 +44,7 @@ using namespace eth;
int eth::g_logVerbosity = 8;
map<type_info const*, bool> eth::g_logOverride;
#if !defined(__APPLE__)
thread_local char const* eth::t_logThreadName = "???";
static char const* g_mainThreadName = (eth::t_logThreadName = "main");
#endif
ThreadLocalLogName eth::t_logThreadName("main");
void eth::simpleDebugOut(std::string const& _s, char const*)
{

24
libethereum/Common.h

@ -39,13 +39,9 @@
#include <cstdint>
#include <type_traits>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/thread.hpp>
#include "vector_ref.h"
// OSX likes GCD whichs runs threads within queues
#if defined(__APPLE__)
#include <dispatch/dispatch.h>
#endif
namespace eth
{
@ -160,10 +156,14 @@ public:
extern std::map<std::type_info const*, bool> g_logOverride;
#if !defined(__APPLE__)
extern thread_local char const* t_logThreadName;
inline void setThreadName(char const* _n) { t_logThreadName = _n; }
#endif
struct ThreadLocalLogName
{
ThreadLocalLogName(std::string _name) { m_name.reset(new std::string(_name)); };
boost::thread_specific_ptr<std::string> m_name;
};
extern ThreadLocalLogName t_logThreadName;
inline void setThreadName(char const* _n) { t_logThreadName.m_name.reset(new std::string(_n)); }
struct LogChannel { static const char constexpr* name = " "; static const int verbosity = 1; };
struct LeftChannel: public LogChannel { static const char constexpr* name = "<<<"; };
@ -191,11 +191,7 @@ public:
char buf[24];
if (strftime(buf, 24, "%X", localtime(&rawTime)) == 0)
buf[0] = '\0'; // empty if case strftime fails
#if defined(__APPLE__)
sstr << Id::name << " [ " << buf << " | " << dispatch_queue_get_label(dispatch_get_current_queue()) << (_term ? " ] " : "");
#else
sstr << Id::name << " [ " << buf << " | " << t_logThreadName << (_term ? " ] " : "");
#endif
sstr << Id::name << " [ " << buf << " | " << *(t_logThreadName.m_name.get()) << (_term ? " ] " : "");
}
}
~LogOutputStream() { if (Id::verbosity <= g_logVerbosity) g_logPost(sstr.str(), Id::name); }

Loading…
Cancel
Save