adding namespace sls to public receiver api

This commit is contained in:
Erik Frojdh 2020-11-09 11:23:11 +01:00
parent 121a3ad733
commit 2020407438
8 changed files with 24 additions and 9 deletions

View File

@ -11,6 +11,8 @@
#include <semaphore.h>
#include <vector>
namespace sls{
/** Circular Fifo (a.k.a. Circular Buffer)
* Thread safe for one reader, and one writer */
template <typename Element> class CircularFifo {
@ -127,3 +129,5 @@ size_t CircularFifo<Element>::increment(size_t i) const {
i = (i + 1) % capacity;
return i;
}
}

View File

@ -4,6 +4,9 @@
class ClientInterface;
namespace sls
{
class Receiver : private virtual slsDetectorDefs {
public:
@ -86,3 +89,5 @@ class Receiver : private virtual slsDetectorDefs {
private:
std::unique_ptr<ClientInterface> tcpipInterface;
};
} // namespace sls

View File

@ -33,9 +33,9 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
DestroyFifos();
// create fifos
fifoBound = new CircularFifo<char>(fifoDepth);
fifoFree = new CircularFifo<char>(fifoDepth);
fifoStream = new CircularFifo<char>(fifoDepth);
fifoBound = new sls::CircularFifo<char>(fifoDepth);
fifoFree = new sls::CircularFifo<char>(fifoDepth);
fifoStream = new sls::CircularFifo<char>(fifoDepth);
// allocate memory
size_t mem_len = (size_t)fifoItemSize * (size_t)fifoDepth * sizeof(char);
memory = (char *)malloc(mem_len);

View File

@ -92,13 +92,13 @@ class Fifo : private virtual slsDetectorDefs {
char *memory;
/** Circular Fifo pointing to addresses of bound data in memory */
CircularFifo<char> *fifoBound;
sls::CircularFifo<char> *fifoBound;
/** Circular Fifo pointing to addresses of freed data in memory */
CircularFifo<char> *fifoFree;
sls::CircularFifo<char> *fifoFree;
/** Circular Fifo pointing to addresses of to be streamed data in memory */
CircularFifo<char> *fifoStream;
sls::CircularFifo<char> *fifoStream;
/** Fifo depth set */
int fifoDepth;

View File

@ -216,9 +216,9 @@ int main(int argc, char *argv[]) {
cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i,
(long)syscall(SYS_gettid));
std::unique_ptr<Receiver> receiver = nullptr;
std::unique_ptr<sls::Receiver> receiver = nullptr;
try {
receiver = sls::make_unique<Receiver>(startTCPPort + i);
receiver = sls::make_unique<sls::Receiver>(startTCPPort + i);
} catch (...) {
LOG(logINFOBLUE)
<< "Exiting Child Process [ Tid: " << syscall(SYS_gettid)

View File

@ -15,6 +15,8 @@
#include <sys/syscall.h>
#include <unistd.h>
namespace sls{
Receiver::~Receiver() = default;
Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
@ -142,3 +144,5 @@ void Receiver::registerCallBackRawDataModifyReady(
void (*func)(char *, char *, uint32_t &, void *), void *arg) {
tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
}
}

View File

@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
}
try {
Receiver r(argc, argv);
sls::Receiver r(argc, argv);
LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
sem_wait(&semaphore);
sem_destroy(&semaphore);

View File

@ -2,6 +2,8 @@
#include "catch.hpp"
#include <vector>
using sls::CircularFifo;
TEST_CASE("Empty buffer") {
CircularFifo<char> fifo(0);