MCPcopy Create free account
hub / github.com/Haivision/srt / worker

Method worker

srtcore/queue.cpp:517–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

515#endif
516
517void* srt::CSndQueue::worker(void* param)
518{
519 CSndQueue* self = (CSndQueue*)param;
520
521 std::string thname;
522 ThreadName::get(thname);
523 THREAD_STATE_INIT(thname.c_str());
524
525#if defined(SRT_DEBUG_SNDQ_HIGHRATE)
526#define IF_DEBUG_HIGHRATE(statement) statement
527 self->m_DbgTime = sync::steady_clock::now();
528 self->m_DbgPeriod = sync::microseconds_from(5000000);
529 self->m_DbgTime += self->m_DbgPeriod;
530#else
531#define IF_DEBUG_HIGHRATE(statement) (void)0
532#endif /* SRT_DEBUG_SNDQ_HIGHRATE */
533
534 while (!self->m_bClosing)
535 {
536 const steady_clock::time_point next_time = self->m_pSndUList->getNextProcTime();
537
538 INCREMENT_THREAD_ITERATIONS();
539
540 IF_DEBUG_HIGHRATE(self->m_WorkerStats.lIteration++);
541
542 if (is_zero(next_time))
543 {
544 IF_DEBUG_HIGHRATE(self->m_WorkerStats.lNotReadyTs++);
545
546 // wait here if there is no sockets with data to be sent
547 THREAD_PAUSED();
548 if (!self->m_bClosing)
549 {
550 self->m_pSndUList->waitNonEmpty();
551 IF_DEBUG_HIGHRATE(self->m_WorkerStats.lCondWait++);
552 }
553 THREAD_RESUMED();
554
555 continue;
556 }
557
558 // wait until next processing time of the first socket on the list
559 const steady_clock::time_point currtime = steady_clock::now();
560
561 IF_DEBUG_HIGHRATE(CSndQueueDebugHighratePrint(self, currtime));
562 if (currtime < next_time)
563 {
564 THREAD_PAUSED();
565 self->m_pTimer->sleep_until(next_time);
566 THREAD_RESUMED();
567 IF_DEBUG_HIGHRATE(self->m_WorkerStats.lSleepTo++);
568 }
569
570 // Get a socket with a send request if any.
571 CUDT* u = self->m_pSndUList->pop();
572 if (u == NULL)
573 {
574 IF_DEBUG_HIGHRATE(self->m_WorkerStats.lNotReadyPop++);

Callers

nothing calls this directly

Calls 15

CONIDMethod · 0.95
getIPversionMethod · 0.95
worker_RetrieveUnitMethod · 0.95
CONIDMethod · 0.95
microseconds_fromFunction · 0.85
is_zeroFunction · 0.85
ConnectStatusStrFunction · 0.85
c_strMethod · 0.80
getNextProcTimeMethod · 0.80

Tested by

no test coverage detected