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