+30
-32
lines changedFilter options
+30
-32
lines changed Original file line number Diff line number Diff line change
@@ -240,8 +240,8 @@ class Engine
240
240
void Start()
241
241
{
242
242
Verb() << "START: " << media[DIR_IN]->uri() << " --> " << media[DIR_OUT]->uri();
243
-
std::string thrn = media[DIR_IN]->id() + ">" + media[DIR_OUT]->id();
244
-
srt::ThreadName tn(thrn.c_str());
243
+
const std::string thrn = media[DIR_IN]->id() + ">" + media[DIR_OUT]->id();
244
+
srt::ThreadName tn(thrn);
245
245
246
246
thr = thread([this]() { Worker(); });
247
247
}
Original file line number Diff line number Diff line change
@@ -154,9 +154,7 @@ bool srt::CUDTSocket::readReady()
154
154
if (m_UDT.m_bConnected && m_UDT.m_pRcvBuffer->isRcvDataReady())
155
155
return true;
156
156
if (m_UDT.m_bListening)
157
-
{
158
-
return m_QueuedSockets.size() > 0;
159
-
}
157
+
return !m_QueuedSockets.empty();
160
158
161
159
return broken();
162
160
}
@@ -955,7 +953,7 @@ int srt::CUDTUnited::bind(CUDTSocket* s, UDPSOCKET udpsock)
955
953
s->m_Status = SRTS_OPENED;
956
954
957
955
// copy address information of local node
958
-
s->core().m_pSndQueue->m_pChannel->getSockAddr((s->m_SelfAddr));
956
+
s->core().m_pSndQueue->m_pChannel->getSockAddr(s->m_SelfAddr);
959
957
960
958
return 0;
961
959
}
@@ -1535,7 +1533,7 @@ int srt::CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets, i
1535
1533
HLOGC(aclog.Debug, log << "groupConnect: connecting a new socket with ISN=" << isn);
1536
1534
connectIn(ns, target_addr, isn);
1537
1535
}
1538
-
catch (CUDTException& e)
1536
+
catch (const CUDTException& e)
1539
1537
{
1540
1538
LOGC(aclog.Error, log << "groupConnect: socket @" << sid << " in group " << pg->id() << " failed to connect");
1541
1539
// We know it does belong to a group.
Original file line number Diff line number Diff line change
@@ -9395,10 +9395,10 @@ int srt::CUDT::processData(CUnit* in_unit)
9395
9395
9396
9396
const string& tn = tns2.str();
9397
9397
9398
-
ThreadName tnkeep(tn.c_str());
9399
-
const char* thname = tn.c_str();
9398
+
ThreadName tnkeep(tn);
9399
+
const string& thname = tn;
9400
9400
#else
9401
-
const char* thname = "SRT:TsbPd";
9401
+
const string thname = "SRT:TsbPd";
9402
9402
#endif
9403
9403
if (!StartThread(m_RcvTsbPdThread, CUDT::tsbpd, this, thname))
9404
9404
return -1;
Original file line number Diff line number Diff line change
@@ -79,9 +79,9 @@ std::string FormatTimeSys(const steady_clock::time_point& timestamp)
79
79
80
80
81
81
#ifdef ENABLE_STDCXX_SYNC
82
-
bool StartThread(CThread& th, ThreadFunc&& f, void* args, const char* name)
82
+
bool StartThread(CThread& th, ThreadFunc&& f, void* args, const string& name)
83
83
#else
84
-
bool StartThread(CThread& th, void* (*f) (void*), void* args, const char* name)
84
+
bool StartThread(CThread& th, void* (*f) (void*), void* args, const string& name)
85
85
#endif
86
86
{
87
87
ThreadName tn(name);
Original file line number Diff line number Diff line change
@@ -843,9 +843,9 @@ namespace this_thread
843
843
///
844
844
#ifdef ENABLE_STDCXX_SYNC
845
845
typedef void* (&ThreadFunc) (void*);
846
-
bool StartThread(CThread& th, ThreadFunc&& f, void* args, const char* name);
846
+
bool StartThread(CThread& th, ThreadFunc&& f, void* args, const std::string& name);
847
847
#else
848
-
bool StartThread(CThread& th, void* (*f) (void*), void* args, const char* name);
848
+
bool StartThread(CThread& th, void* (*f) (void*), void* args, const std::string& name);
849
849
#endif
850
850
851
851
////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
@@ -111,9 +111,9 @@ class ThreadName
111
111
#endif
112
112
}
113
113
114
-
ThreadNameImpl(const char* name)
114
+
explicit ThreadNameImpl(const char* name)
115
+
: reset(false)
115
116
{
116
-
reset = false;
117
117
tid = pthread_self();
118
118
119
119
if (!get(old_name))
@@ -140,6 +140,10 @@ class ThreadName
140
140
if (tid == pthread_self())
141
141
set(old_name);
142
142
}
143
+
144
+
private:
145
+
ThreadNameImpl(ThreadNameImpl& other);
146
+
ThreadNameImpl& operator=(const ThreadNameImpl& other);
143
147
144
148
private:
145
149
bool reset;
@@ -202,21 +206,17 @@ class ThreadName
202
206
return ret;
203
207
}
204
208
205
-
// note: set can fail if name is too long. The upper limit is platform
206
-
// dependent. strlen(name) <= 15 should work on most of the platform.
207
-
static bool set(const char* name) { return ThreadNameImpl::set(name); }
208
-
209
-
static bool set(const std::string& name) { return set(name.c_str()); }
210
-
211
-
ThreadName(const char* name)
212
-
: impl(name)
213
-
{
214
-
}
209
+
static bool set(const std::string& name) { return ThreadNameImpl::set(name.c_str()); }
215
210
216
-
ThreadName(const std::string& name)
211
+
explicit ThreadName(const std::string& name)
217
212
: impl(name.c_str())
218
213
{
219
214
}
215
+
216
+
private:
217
+
ThreadName(const ThreadName&);
218
+
ThreadName(const char*);
219
+
ThreadName& operator=(const ThreadName& other);
220
220
};
221
221
222
222
} // namespace srt
Original file line number Diff line number Diff line change
@@ -28,12 +28,12 @@ TEST(ThreadName, GetSet)
28
28
29
29
TEST(ThreadName, AutoReset)
30
30
{
31
-
std::string old_name("old");
31
+
const std::string old_name("old");
32
32
std::string new_name("new-name");
33
33
if (ThreadName::DUMMY_IMPL)
34
34
{
35
35
// just make sure the API is correct
36
-
ThreadName t("test");
36
+
ThreadName t(std::string("test"));
37
37
return;
38
38
}
39
39
Original file line number Diff line number Diff line change
@@ -196,7 +196,7 @@ class MediaBase
196
196
med.name = name;
197
197
198
198
// Ok, got this, so we can start transmission.
199
-
srt::ThreadName tn(thread_name.c_str());
199
+
srt::ThreadName tn(thread_name);
200
200
201
201
med.runner = thread( [&med]() { med.TransmissionLoop(); });
202
202
return med;
Original file line number Diff line number Diff line change
@@ -438,7 +438,7 @@ void SrtMainLoop::run()
438
438
439
439
std::ostringstream tns;
440
440
tns << "Input:" << this;
441
-
srt::ThreadName tn(tns.str().c_str());
441
+
srt::ThreadName tn(tns.str());
442
442
m_input_thr = thread([this] {
443
443
try {
444
444
InputRunner();
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ struct Medium
58
58
running = true;
59
59
std::ostringstream tns;
60
60
tns << typeid(*this).name() << ":" << this;
61
-
srt::ThreadName tn(tns.str().c_str());
61
+
srt::ThreadName tn(tns.str());
62
62
thr = thread( [this] { RunnerBase(); } );
63
63
}
64
64
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4