aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/DriveLoop.cpp
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2013-07-14 12:42:52 +0400
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2013-07-14 23:11:54 +0400
commitde202e343564913e0591de10850e617d7de55b6b (patch)
tree1e45714611d2f02462c1d7bc883ed6f534014335 /Transceiver52M/DriveLoop.cpp
parente279124660a2add686e6c9266d18a9bb0cf43258 (diff)
Transceiver52M: Port all threads to the new Thread interface.
Also note that we introduced shutdown() method for Transceiver threads which implement proper shutdown of threads when they are in blocking read state. This involves using shutdown() on sockets and pushing NULL to queues. With this change we should be able to start/stop transceiver channels at arbitrary moments.
Diffstat (limited to 'Transceiver52M/DriveLoop.cpp')
-rw-r--r--Transceiver52M/DriveLoop.cpp39
1 files changed, 10 insertions, 29 deletions
diff --git a/Transceiver52M/DriveLoop.cpp b/Transceiver52M/DriveLoop.cpp
index f2e81c6..51ce750 100644
--- a/Transceiver52M/DriveLoop.cpp
+++ b/Transceiver52M/DriveLoop.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2008, 2009, 2010, 2012 Free Software Foundation, Inc.
+* Copyright 2013 Alexander Chemeris <Alexander.Chemeris@fairwaves.ru>
*
* This software is distributed under the terms of the GNU Public License.
* See the COPYING file in the main directory for details.
@@ -31,10 +32,11 @@ DriveLoop::DriveLoop(int wBasePort, const char *TRXAddress,
RadioInterface *wRadioInterface,
int wChanM, int wC0, int wSamplesPerSymbol,
GSM::Time wTransmitLatency)
- :mClockSocket(wBasePort, TRXAddress, wBasePort + 100), mC0(wC0)
+: Thread("DriveLoop")
+, mClockSocket(wBasePort, TRXAddress, wBasePort + 100)
+, mC0(wC0)
{
mChanM = wChanM;
- mRadioDriveLoopThread = NULL;
mSamplesPerSymbol = wSamplesPerSymbol;
mRadioInterface = wRadioInterface;
@@ -74,33 +76,15 @@ DriveLoop::DriveLoop(int wBasePort, const char *TRXAddress,
mChanType[n][i] = NONE;
}
}
-
- mOn = false;
}
DriveLoop::~DriveLoop()
{
- if (mOn) {
- mOn = false;
-
- if (mRadioDriveLoopThread)
- delete mRadioDriveLoopThread;
- }
-
+ stopThread();
delete gsmPulse;
sigProcLibDestroy();
}
-void DriveLoop::start()
-{
- if (mOn)
- return;
-
- mOn = true;
- mRadioDriveLoopThread = new Thread(32768);
- mRadioDriveLoopThread->start((void * (*)(void*))RadioDriveLoopAdapter, (void*) this);
-}
-
void DriveLoop::pushRadioVector(GSM::Time &nowTime)
{
int i;
@@ -273,15 +257,12 @@ void DriveLoop::writeClockInterface()
mLastClockUpdateTime = mTransmitDeadlineClock;
}
-void *RadioDriveLoopAdapter(DriveLoop *drive)
+void DriveLoop::runThread()
{
- drive->setPriority();
+ setPriority();
- while (drive->on()) {
- drive->driveReceiveFIFO();
- drive->driveTransmitFIFO();
- pthread_testcancel();
+ while (isThreadRunning()) {
+ driveReceiveFIFO();
+ driveTransmitFIFO();
}
-
- return NULL;
}