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

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

Issue 48123: Added a wait with timeout to the platform semaphore class (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-win32.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 558
559 ~MacOSSemaphore() { 559 ~MacOSSemaphore() {
560 semaphore_destroy(mach_task_self(), semaphore_); 560 semaphore_destroy(mach_task_self(), semaphore_);
561 } 561 }
562 562
563 // The MacOS mach semaphore documentation claims it does not have spurious 563 // The MacOS mach semaphore documentation claims it does not have spurious
564 // wakeups, the way pthreads semaphores do. So the code from the linux 564 // wakeups, the way pthreads semaphores do. So the code from the linux
565 // platform is not needed here. 565 // platform is not needed here.
566 void Wait() { semaphore_wait(semaphore_); } 566 void Wait() { semaphore_wait(semaphore_); }
567 567
568 bool Wait(int timeout);
569
568 void Signal() { semaphore_signal(semaphore_); } 570 void Signal() { semaphore_signal(semaphore_); }
569 571
570 private: 572 private:
571 semaphore_t semaphore_; 573 semaphore_t semaphore_;
572 }; 574 };
573 575
574 576
577 bool MacOSSemaphore::Wait(int timeout) {
578 mach_timespec_t ts;
579 ts.tv_sec = timeout / 1000000;
580 ts.tv_nsec = (timeout % 1000000) * 1000;
581 return semaphore_timedwait(semaphore_, ts) != KERN_OPERATION_TIMED_OUT;
582 }
583
584
575 Semaphore* OS::CreateSemaphore(int count) { 585 Semaphore* OS::CreateSemaphore(int count) {
576 return new MacOSSemaphore(count); 586 return new MacOSSemaphore(count);
577 } 587 }
578 588
579 589
580 // ---------------------------------------------------------------------------- 590 // ----------------------------------------------------------------------------
581 // MacOS socket support. 591 // MacOS socket support.
582 // 592 //
583 593
584 class MacOSSocket : public Socket { 594 class MacOSSocket : public Socket {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 } 837 }
828 838
829 // This sampler is no longer the active sampler. 839 // This sampler is no longer the active sampler.
830 active_sampler_ = NULL; 840 active_sampler_ = NULL;
831 active_ = false; 841 active_ = false;
832 } 842 }
833 843
834 #endif // ENABLE_LOGGING_AND_PROFILING 844 #endif // ENABLE_LOGGING_AND_PROFILING
835 845
836 } } // namespace v8::internal 846 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698