From 61c90ed1c4f8a63b323a9b471f27fb08c86aa570 Mon Sep 17 00:00:00 2001 From: Rafal Krypa Date: Mon, 2 Jun 2014 19:10:59 +0200 Subject: [PATCH] DPL: work around for dependency on DPL::Thread Patch based on work by similar work by Zofia Abramowska. Include needed parts from DPL::Thread into code of NaiveSynchronizationObject. Only NanoSleep() and MiliSleep() methods are needed and the original DPL::Thread() triggers a large chain of dependencies, including EFL. Change-Id: Icf8257ca8eeaa5cdbc4d80ceb98d88aceeec7821 Signed-off-by: Rafal Krypa --- .../dpl/db/src/naive_synchronization_object.cpp | 43 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/server/dpl/db/src/naive_synchronization_object.cpp b/src/server/dpl/db/src/naive_synchronization_object.cpp index 1ac71ca..63f1dd7 100644 --- a/src/server/dpl/db/src/naive_synchronization_object.cpp +++ b/src/server/dpl/db/src/naive_synchronization_object.cpp @@ -22,12 +22,53 @@ */ #include #include -#include +#include +#include namespace { unsigned int seed = time(NULL); } +//Taken from Thread class, so we don't have to pull whole definition +//(only this part is needed) +namespace Thread { + +static const size_t NANOSECONDS_PER_SECOND = + static_cast(1000 * 1000 * 1000); + +static const size_t NANOSECONDS_PER_MILISECOND = + static_cast(1000 * 1000); + +void NanoSleep(uint64_t nanoseconds) +{ + timespec requestedTime = { + static_cast( + nanoseconds / NANOSECONDS_PER_SECOND), + + static_cast( + nanoseconds % NANOSECONDS_PER_SECOND) + }; + + timespec remainingTime; + + for (;;) { + if (nanosleep(&requestedTime, &remainingTime) == 0) { + break; + } + + int error = errno; + Assert(error == EINTR); + + requestedTime = remainingTime; + } +} + +void MiliSleep(uint64_t miliseconds) +{ + NanoSleep(miliseconds * NANOSECONDS_PER_MILISECOND); +} +} + namespace DPL { namespace DB { void NaiveSynchronizationObject::Synchronize() -- 2.7.4