aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/Transceiver.cpp
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-07-22 18:10:52 +0200
committerpespin <pespin@sysmocom.de>2019-07-23 09:06:01 +0000
commit720b912ba9c8e51a40451e9cc44b3cc0bac698c2 (patch)
treea74e170f2862f33096b1587db2dbee91a7227d72 /Transceiver52M/Transceiver.cpp
parentc3325b9aeb446f2cc888523d8c9f5f4ff3a39242 (diff)
Transceiver: Clean up code passing parameters to threads
TransceiverChannel naming was misleading there. It's simply a data type used to pass 2 parameters through the void* of the thread entry function, so let's clearly specify is a storage for thread params. Furthermore, we don't need a full C++ class for that, let's simply use a struct. Change-Id: I6e3898a8a66520cc5b2a7df9b9ae01b0b272387f
Diffstat (limited to 'Transceiver52M/Transceiver.cpp')
-rw-r--r--Transceiver52M/Transceiver.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index a47f7db..b12a498 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -240,10 +240,12 @@ bool Transceiver::init(FillerType filler, size_t rtsc, unsigned rach_delay,
/* Start control threads */
for (size_t i = 0; i < mChans; i++) {
- TransceiverChannel *chan = new TransceiverChannel(this, i);
+ TrxChanThParams *params = (TrxChanThParams *)malloc(sizeof(struct TrxChanThParams));
+ params->trx = this;
+ params->num = i;
mControlServiceLoopThreads[i] = new Thread(stackSize);
mControlServiceLoopThreads[i]->start((void * (*)(void*))
- ControlServiceLoopAdapter, (void*) chan);
+ ControlServiceLoopAdapter, (void*) params);
if (i && filler == FILLER_DUMMY)
filler = FILLER_ZERO;
@@ -292,15 +294,19 @@ bool Transceiver::start()
/* Launch uplink and downlink burst processing threads */
for (size_t i = 0; i < mChans; i++) {
- TransceiverChannel *chan = new TransceiverChannel(this, i);
+ TrxChanThParams *params = (TrxChanThParams *)malloc(sizeof(struct TrxChanThParams));
+ params->trx = this;
+ params->num = i;
mRxServiceLoopThreads[i] = new Thread(stackSize);
mRxServiceLoopThreads[i]->start((void * (*)(void*))
- RxUpperLoopAdapter, (void*) chan);
+ RxUpperLoopAdapter, (void*) params);
- chan = new TransceiverChannel(this, i);
+ params = (TrxChanThParams *)malloc(sizeof(struct TrxChanThParams));
+ params->trx = this;
+ params->num = i;
mTxPriorityQueueServiceLoopThreads[i] = new Thread(stackSize);
mTxPriorityQueueServiceLoopThreads[i]->start((void * (*)(void*))
- TxUpperLoopAdapter, (void*) chan);
+ TxUpperLoopAdapter, (void*) params);
}
mForceClockInterface = true;
@@ -1108,13 +1114,13 @@ void Transceiver::writeClockInterface()
}
-void *RxUpperLoopAdapter(TransceiverChannel *chan)
+void *RxUpperLoopAdapter(TrxChanThParams *params)
{
char thread_name[16];
- Transceiver *trx = chan->trx;
- size_t num = chan->num;
+ Transceiver *trx = params->trx;
+ size_t num = params->num;
- delete chan;
+ free(params);
snprintf(thread_name, 16, "RxUpper%zu", num);
set_selfthread_name(thread_name);
@@ -1154,13 +1160,13 @@ void *TxLowerLoopAdapter(Transceiver *transceiver)
return NULL;
}
-void *ControlServiceLoopAdapter(TransceiverChannel *chan)
+void *ControlServiceLoopAdapter(TrxChanThParams *params)
{
char thread_name[16];
- Transceiver *trx = chan->trx;
- size_t num = chan->num;
+ Transceiver *trx = params->trx;
+ size_t num = params->num;
- delete chan;
+ free(params);
snprintf(thread_name, 16, "CtrlService%zu", num);
set_selfthread_name(thread_name);
@@ -1172,13 +1178,13 @@ void *ControlServiceLoopAdapter(TransceiverChannel *chan)
return NULL;
}
-void *TxUpperLoopAdapter(TransceiverChannel *chan)
+void *TxUpperLoopAdapter(TrxChanThParams *params)
{
char thread_name[16];
- Transceiver *trx = chan->trx;
- size_t num = chan->num;
+ Transceiver *trx = params->trx;
+ size_t num = params->num;
- delete chan;
+ free(params);
snprintf(thread_name, 16, "TxUpper%zu", num);
set_selfthread_name(thread_name);