Skip to content

Commit 5f54fc3

Browse files
asynv
1 parent 94d690a commit 5f54fc3

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

src/tests/integration/test_data_track.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,12 @@ TEST_P(DataTrackTransportTest, PublishesAndReceivesFramesEndToEnd) {
326326
auto subscription = subscribe_result.value();
327327

328328
std::atomic<bool> keep_publishing{true};
329-
std::exception_ptr publish_error;
330-
std::thread publisher([&]() {
331-
try {
332-
DataTrackFrame frame;
333-
frame.payload.assign(payload_len, kTransportPayloadValue);
334-
while (keep_publishing.load()) {
335-
requirePushSuccess(local_track->tryPush(frame), "Failed to push data frame");
336-
std::this_thread::sleep_for(50ms);
337-
}
338-
} catch (...) {
339-
publish_error = std::current_exception();
329+
auto publisher = std::async(std::launch::async, [&]() {
330+
DataTrackFrame frame;
331+
frame.payload.assign(payload_len, kTransportPayloadValue);
332+
while (keep_publishing.load()) {
333+
requirePushSuccess(local_track->tryPush(frame), "Failed to push data frame");
334+
std::this_thread::sleep_for(50ms);
340335
}
341336
});
342337

@@ -350,13 +345,10 @@ TEST_P(DataTrackTransportTest, PublishesAndReceivesFramesEndToEnd) {
350345

351346
const bool remote_track_published_after_read = remote_track->isPublished();
352347
keep_publishing.store(false);
353-
publisher.join();
354348
subscription->close();
355349
local_track->unpublishDataTrack();
356350

357-
if (publish_error) {
358-
std::rethrow_exception(publish_error);
359-
}
351+
publisher.get();
360352
if (read_error) {
361353
std::rethrow_exception(read_error);
362354
}

0 commit comments

Comments
 (0)