Merge pull request #120 from slsdetectorgroup/usleep

Replaced usleep with std::this_thread::sleep_for
This commit is contained in:
Dhanya Thattil 2020-07-23 11:44:30 +02:00 committed by GitHub
commit beb6afe101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 8 deletions

View File

@ -10,6 +10,8 @@
#include "versionAPI.h"
#include <fstream>
#include <chrono>
#include <thread>
namespace sls {
@ -399,7 +401,7 @@ void Detector::setPowerChip(bool on, Positions pos) {
if ((pos.empty() || pos[0] == -1) && on && pimpl->size() > 3) {
for (int i = 0; i != pimpl->size(); ++i) {
pimpl->Parallel(&Module::setPowerChip, {i}, on);
usleep(1000 * 1000);
std::this_thread::sleep_for(std::chrono::seconds(1));
}
} else {
pimpl->Parallel(&Module::setPowerChip, pos, on);

View File

@ -15,6 +15,8 @@
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <thread>
#include <cstdlib>
#include <iomanip>
#include <iterator>
@ -3160,7 +3162,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
const int ERASE_TIME = 65;
int count = ERASE_TIME + 1;
while (count > 0) {
usleep(1 * 1000 * 1000);
std::this_thread::sleep_for(std::chrono::seconds(1));
--count;
printf(
"%d%%\r",

View File

@ -13,6 +13,8 @@
#include <cstring>
#include <cstring> //strcpy
#include <fstream>
#include <chrono>
#include <thread>
#include <iostream>
#include <sys/stat.h> // stat
#include <unistd.h>
@ -739,7 +741,7 @@ void Implementation::stopReceiver() {
for (const auto &it : dataProcessor)
if (it->IsRunning())
running = true;
usleep(5000);
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
// create virtual file
@ -763,7 +765,7 @@ void Implementation::stopReceiver() {
for (const auto &it : dataStreamer)
if (it->IsRunning())
running = true;
usleep(5000);
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
status = RUN_FINISHED;
@ -821,7 +823,8 @@ void Implementation::startReadout() {
<< "waiting for all packets, previousValue:"
<< previousValue
<< " totalPacketsReceived: " << totalPacketsReceived;
usleep(5 * 1000); /* TODO! Need to find optimal time **/
/* TODO! Need to find optimal time **/
std::this_thread::sleep_for(std::chrono::milliseconds(5));
previousValue = totalPacketsReceived;
totalPacketsReceived = 0;
for (const auto &it : listener)

View File

@ -3,7 +3,8 @@
#include <errno.h>
#include <iostream>
#include <string.h>
#include <unistd.h> //usleep in some machines
#include <chrono>
#include <thread>
#include <vector>
#include <sstream>
#include <zmq.h>
@ -76,8 +77,8 @@ ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip)
PrintError();
throw sls::ZmqSocketError("Could not bind socket");
}
// sleep for a few milliseconds to allow a slow-joiner
usleep(200 * 1000);
// sleep to allow a slow-joiner
std::this_thread::sleep_for(std::chrono::milliseconds(200));
};
int ZmqSocket::Connect() {