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

Side by Side Diff: src/platform-macos.cc

Issue 10867009: platform: fix semaphore on mac os Base URL: gh:v8/v8@master
Patch Set: the last lint fix Created 8 years, 3 months 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
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 675
676 676
677 Mutex* OS::CreateMutex() { 677 Mutex* OS::CreateMutex() {
678 return new MacOSMutex(); 678 return new MacOSMutex();
679 } 679 }
680 680
681 681
682 class MacOSSemaphore : public Semaphore { 682 class MacOSSemaphore : public Semaphore {
683 public: 683 public:
684 explicit MacOSSemaphore(int count) { 684 explicit MacOSSemaphore(int count) {
685 semaphore_create(mach_task_self(), &semaphore_, SYNC_POLICY_FIFO, count); 685 int r;
686 r = semaphore_create(mach_task_self(),
687 &semaphore_,
688 SYNC_POLICY_FIFO,
689 count);
690 ASSERT(r == KERN_SUCCESS);
686 } 691 }
687 692
688 ~MacOSSemaphore() { 693 ~MacOSSemaphore() {
689 semaphore_destroy(mach_task_self(), semaphore_); 694 int r;
695 r = semaphore_destroy(mach_task_self(), semaphore_);
696 ASSERT(r == KERN_SUCCESS);
690 } 697 }
691 698
692 // The MacOS mach semaphore documentation claims it does not have spurious 699 void Wait() {
693 // wakeups, the way pthreads semaphores do. So the code from the linux 700 int r;
694 // platform is not needed here. 701 do {
695 void Wait() { semaphore_wait(semaphore_); } 702 r = semaphore_wait(semaphore_);
703 } while (r == KERN_ABORTED);
704
705 ASSERT(r == KERN_SUCCESS);
Erik Corry 2012/08/23 09:23:39 I will move this up into the loop and assert that
706 }
696 707
697 bool Wait(int timeout); 708 bool Wait(int timeout);
698 709
699 void Signal() { semaphore_signal(semaphore_); } 710 void Signal() { semaphore_signal(semaphore_); }
700 711
701 private: 712 private:
702 semaphore_t semaphore_; 713 semaphore_t semaphore_;
703 }; 714 };
704 715
705 716
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 919
909 920
910 void Sampler::Stop() { 921 void Sampler::Stop() {
911 ASSERT(IsActive()); 922 ASSERT(IsActive());
912 SamplerThread::RemoveActiveSampler(this); 923 SamplerThread::RemoveActiveSampler(this);
913 SetActive(false); 924 SetActive(false);
914 } 925 }
915 926
916 927
917 } } // namespace v8::internal 928 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698