Commit 39bd6d97 authored by Pavel Vainerman's avatar Pavel Vainerman

Перешёл на более "каноничное" использование [x]sleep

c использованием возможностей самого языка (c++11) - chrono P.S. заодно попытка провести чистку неиспользуемых #include (из-за этого могут быть проблеммы у тех кто не делал у себя include)
parent 68a44a00
......@@ -14,7 +14,7 @@
Name: libuniset2
Version: 2.5
Release: alt6
Release: alt7
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
......@@ -486,6 +486,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Fri Sep 02 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt7
- usleep --> std::this_thread::sleep_for(..);
- clean up #include ...
* Thu Sep 01 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt6
- (python): add getObjectID() for python UInterface
......
......@@ -18,6 +18,7 @@
#include <cstring>
#include <getopt.h>
#include <time.h>
#include <unistd.h>
#include <string>
#include <iostream>
......@@ -320,7 +321,7 @@ int main(int argc, char* argv[])
}
}
usleep(1000000);
std::this_thread::sleep_for(std::chrono::seconds(1));
}
return 0;
......
......@@ -14,6 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// -------------------------------------------------------------------------
#include <chrono>
#include <thread>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -298,7 +300,7 @@ int main(int argc, char* argv[])
break;
val = val ? 0 : 1;
usleep(1000 * blink_msec);
std::this_thread::sleep_for(std::chrono::milliseconds(blink_msec));
}
}
break;
......
......@@ -127,7 +127,7 @@ static void run_senders( size_t max, const std::string& s_host, size_t count = 5
}
usleep(usecpause);
std::this_thread::sleep_for(std::chrono::microseconds(usecpause));
}
}
// --------------------------------------------------------------------------
......
......@@ -4,6 +4,7 @@
#include <cstring>
#include <iostream>
#include <chrono>
#include <thread>
#include <iomanip>
#include <Poco/Net/NetException.h>
#include "UDPPacket.h"
......@@ -357,7 +358,7 @@ int main(int argc, char* argv[])
break;
}
usleep(usecpause);
std::this_thread::sleep_for(std::chrono::microseconds(usecpause));
}
}
break;
......
......@@ -96,7 +96,8 @@ void CallbackTimer<Caller>::terminate()
{
// timeAct = 0;
terminated = true;
usleep(1000);
//usleep(1000);
std::this_thread::sleep_for(std::chrono::microseconds(1));
}
// ------------------------------------------------------------------------------------------
......
......@@ -22,12 +22,10 @@
#define Object_LT_H_
//--------------------------------------------------------------------------
#include <deque>
#include <time.h>
#include "UniSetTypes.h"
#include "MessageType.h"
#include "PassiveTimer.h"
#include "Exceptions.h"
//---------------------------------------------------------------------------
class UniSetObject;
//---------------------------------------------------------------------------
......
......@@ -22,7 +22,7 @@
#ifndef MessageType_H_
#define MessageType_H_
// --------------------------------------------------------------------------
#include <sys/time.h>
#include <time.h> // for timespec
#include <cstring>
#include <ostream>
#include "UniSetTypes.h"
......
......@@ -27,8 +27,6 @@
#include <thread>
#include <mutex>
#include <atomic>
#include <unistd.h>
#include <sys/time.h>
#include <ostream>
#include <memory>
#include <string>
......
......@@ -30,7 +30,8 @@
#include <vector>
#include <limits>
#include <ostream>
#include <unistd.h>
#include <chrono>
#include <thread>
#include <omniORB4/CORBA.h>
#include "UniSetTypes_i.hh"
......@@ -41,7 +42,7 @@
/*! Задержка в миллисекундах */
inline void msleep( unsigned int m )
{
usleep(m * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(m));
}
/*! Определения базовых типов библиотеки UniSet (вспомогательные типы данных, константы, полезные функции) */
......
......@@ -131,7 +131,7 @@ unsigned char ComPort485F::m_receiveByte( bool wait )
}
}
usleep(3000);
std::this_thread::sleep_for(std::chrono::microseconds(3));
}
if ( ptRecv.checkTime() )
......@@ -149,7 +149,7 @@ unsigned char ComPort485F::m_receiveByte( bool wait )
break;
}
usleep(3000);
std::this_thread::sleep_for(std::chrono::microseconds(3));
}
}
......@@ -308,7 +308,7 @@ void ComPort485F::m_read( timeout_t tmsec )
}
}
usleep(3000);
std::this_thread::sleep_for(std::chrono::microseconds(3));
}
}
// --------------------------------------------------------------------------------
......
......@@ -355,7 +355,7 @@ mbErrCode ModbusClient::recv( ModbusAddr addr, ModbusByte qfunc,
break;
}
usleep(sleepPause_usec);
std::this_thread::sleep_for(std::chrono::microseconds(sleepPause_usec));
}
if( !begin )
......
......@@ -20,6 +20,7 @@
// -----------------------------------------------------------------------------------------
#include <sstream>
#include <fstream>
#include <unistd.h>
#include "IORFile.h"
#include "Configuration.h"
#include "ORepHelpers.h"
......
......@@ -20,7 +20,8 @@
// --------------------------------------------------------------------------
#include <unistd.h>
#include <stream.h>
#include <chrono>
#include <thread>
#include <stdio.h>
// #include "WaitingPassiveTimer.h"
#include "PassiveTimer.h"
......@@ -84,7 +85,7 @@ void WaitingPassiveTimer::work()
while( !terminated )
{
usleep(sleepMKS);
std::this_thread::sleep_for(std::chrono::microseconds(sleepMKS));
if ( checkTime() )
break;
......@@ -115,7 +116,7 @@ void WaitingPassiveTimer::terminate()
{
timeAct = 0;
terminated = true;
usleep(1000);
std::this_thread::sleep_for(std::chrono::microseconds(1));
}
// ------------------------------------------------------------------------------------------
void WaitingPassiveTimer::wait(timeout_t timeMS)
......
......@@ -20,6 +20,7 @@
*/
// --------------------------------------------------------------------------
#include <dirent.h>
#include <unistd.h>
#include "RunLock.h"
#include "Configuration.h"
// --------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment