| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |