Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Side by Side Diff: webrtc/test/channel_transport/udp_socket2_manager_win.cc

Issue 1476453002: Clean up PlatformThread. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: IsRunning DCHECK Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 itemsFreed++; 513 itemsFreed++;
514 pListEntry = InterlockedPopEntrySList(_pListHead); 514 pListEntry = InterlockedPopEntrySList(_pListHead);
515 } 515 }
516 return itemsFreed; 516 return itemsFreed;
517 } 517 }
518 518
519 int32_t UdpSocket2WorkerWindows::_numOfWorkers = 0; 519 int32_t UdpSocket2WorkerWindows::_numOfWorkers = 0;
520 520
521 UdpSocket2WorkerWindows::UdpSocket2WorkerWindows(HANDLE ioCompletionHandle) 521 UdpSocket2WorkerWindows::UdpSocket2WorkerWindows(HANDLE ioCompletionHandle)
522 : _ioCompletionHandle(ioCompletionHandle), 522 : _ioCompletionHandle(ioCompletionHandle),
523 _init(false) 523 _pThread(Run, this, "UdpSocket2ManagerWindows_thread"),
524 { 524 _init(false) {
525 _workerNumber = _numOfWorkers++; 525 _workerNumber = _numOfWorkers++;
526 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, 526 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
527 "UdpSocket2WorkerWindows created"); 527 "UdpSocket2WorkerWindows created");
528 } 528 }
529 529
530 UdpSocket2WorkerWindows::~UdpSocket2WorkerWindows() 530 UdpSocket2WorkerWindows::~UdpSocket2WorkerWindows()
531 { 531 {
532 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, 532 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1,
533 "UdpSocket2WorkerWindows deleted"); 533 "UdpSocket2WorkerWindows deleted");
534 } 534 }
535 535
536 bool UdpSocket2WorkerWindows::Start() 536 bool UdpSocket2WorkerWindows::Start()
537 { 537 {
538 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, 538 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
539 "Start UdpSocket2WorkerWindows"); 539 "Start UdpSocket2WorkerWindows");
540 if (!_pThread->Start()) 540 _pThread.Start();
541 return false;
542 541
543 _pThread->SetPriority(kRealtimePriority); 542 _pThread.SetPriority(rtc::kRealtimePriority);
544 return true; 543 return true;
545 } 544 }
546 545
547 bool UdpSocket2WorkerWindows::Stop() 546 bool UdpSocket2WorkerWindows::Stop()
548 { 547 {
549 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, 548 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1,
550 "Stop UdpSocket2WorkerWindows"); 549 "Stop UdpSocket2WorkerWindows");
551 return _pThread->Stop(); 550 _pThread.Stop();
551 return true;
552 } 552 }
553 553
554 int32_t UdpSocket2WorkerWindows::Init() 554 int32_t UdpSocket2WorkerWindows::Init()
555 { 555 {
556 if(!_init) 556 _init = true;
557 { 557 return 0;
558 const char* threadName = "UdpSocket2ManagerWindows_thread";
559 _pThread = PlatformThread::CreateThread(Run, this, threadName);
560 _init = true;
561 }
562 return 0;
563 } 558 }
564 559
565 bool UdpSocket2WorkerWindows::Run(void* obj) 560 bool UdpSocket2WorkerWindows::Run(void* obj)
566 { 561 {
567 UdpSocket2WorkerWindows* pWorker = 562 UdpSocket2WorkerWindows* pWorker =
568 static_cast<UdpSocket2WorkerWindows*>(obj); 563 static_cast<UdpSocket2WorkerWindows*>(obj);
569 return pWorker->Process(); 564 return pWorker->Process();
570 } 565 }
571 566
572 // Process should always return true. Stopping the worker threads is done in 567 // Process should always return true. Stopping the worker threads is done in
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 _workerNumber); 599 _workerNumber);
605 return true; 600 return true;
606 } 601 }
607 pIOContext = (PerIoContext*)pOverlapped; 602 pIOContext = (PerIoContext*)pOverlapped;
608 pSocket->IOCompleted(pIOContext,ioSize,error); 603 pSocket->IOCompleted(pIOContext,ioSize,error);
609 return true; 604 return true;
610 } 605 }
611 606
612 } // namespace test 607 } // namespace test
613 } // namespace webrtc 608 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/channel_transport/udp_socket2_manager_win.h ('k') | webrtc/test/channel_transport/udp_socket_manager_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698