- avoid dependency on resip/rutil library
This commit is contained in:
parent
5b3c57b750
commit
018ddf81df
|
|
@ -44,23 +44,20 @@ SocketHeap::~SocketHeap()
|
|||
|
||||
void SocketHeap::start()
|
||||
{
|
||||
#if defined(USE_RESIP_INTEGRATION)
|
||||
if (!mId)
|
||||
run();
|
||||
#else
|
||||
#endif
|
||||
if (!mWorkerThread)
|
||||
mWorkerThread = std::make_shared<std::thread>(&SocketHeap::thread, this);
|
||||
}
|
||||
|
||||
void SocketHeap::stop()
|
||||
{
|
||||
#if defined(USE_RESIP_INTEGRATION)
|
||||
if (mId)
|
||||
if (mWorkerThread)
|
||||
{
|
||||
shutdown();
|
||||
// Wait for worker thread
|
||||
join();
|
||||
mShutdown = true;
|
||||
if (mWorkerThread->joinable())
|
||||
mWorkerThread->join();
|
||||
|
||||
mWorkerThread.reset();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SocketHeap::setRange(unsigned short start, unsigned short finish)
|
||||
|
|
@ -222,7 +219,7 @@ void SocketHeap::thread()
|
|||
/*#ifdef __linux__
|
||||
// TODO: make epoll implementation for massive polling
|
||||
#else*/
|
||||
mId = ThreadIf::selfId();
|
||||
mThreadId = std::this_thread::get_id();
|
||||
|
||||
while (!isShutdown())
|
||||
{
|
||||
|
|
@ -288,7 +285,7 @@ void SocketHeap::thread()
|
|||
else
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
mId = 0;
|
||||
|
||||
mShutdown = false;
|
||||
//#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,7 @@ public:
|
|||
};
|
||||
|
||||
// Class allocates new UDP sockets and tracks incoming packets on them. It runs in separate thread
|
||||
#ifdef USE_RESIP_INTEGRATION
|
||||
class SocketHeap: public resip::ThreadIf
|
||||
#else
|
||||
class SocketHeap: public std::thread
|
||||
#endif
|
||||
class SocketHeap
|
||||
{
|
||||
public:
|
||||
enum Multiplex
|
||||
|
|
@ -43,7 +39,7 @@ public:
|
|||
};
|
||||
|
||||
SocketHeap(unsigned short start, unsigned short finish);
|
||||
~SocketHeap();
|
||||
virtual ~SocketHeap();
|
||||
|
||||
static SocketHeap& instance();
|
||||
|
||||
|
|
@ -104,9 +100,13 @@ protected:
|
|||
|
||||
char mTempPacket[MAX_UDPPACKET_SIZE];
|
||||
|
||||
int mId = 0;
|
||||
//bool isShutdown() const { return mShutdown; }
|
||||
virtual void thread();
|
||||
std::shared_ptr<std::thread> mWorkerThread;
|
||||
|
||||
std::thread::id mThreadId;
|
||||
bool mShutdown = false;
|
||||
bool isShutdown() const { return mShutdown; }
|
||||
|
||||
void thread();
|
||||
|
||||
// Processes mDeleteVector -> updates mSocketMap, removes socket items and closes sockets specified in mDeleteVector
|
||||
void processDeleted();
|
||||
|
|
|
|||
Loading…
Reference in New Issue