| OLD | NEW |
| 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 3743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3754 | 3754 |
| 3755 | 3755 |
| 3756 void LockingCommandMessageQueue::Clear() { | 3756 void LockingCommandMessageQueue::Clear() { |
| 3757 ScopedLock sl(lock_); | 3757 ScopedLock sl(lock_); |
| 3758 queue_.Clear(); | 3758 queue_.Clear(); |
| 3759 } | 3759 } |
| 3760 | 3760 |
| 3761 | 3761 |
| 3762 MessageDispatchHelperThread::MessageDispatchHelperThread(Isolate* isolate) | 3762 MessageDispatchHelperThread::MessageDispatchHelperThread(Isolate* isolate) |
| 3763 : Thread("v8:MsgDispHelpr"), | 3763 : Thread("v8:MsgDispHelpr"), |
| 3764 sem_(OS::CreateSemaphore(0)), mutex_(OS::CreateMutex()), | 3764 isolate_(isolate), sem_(OS::CreateSemaphore(0)), |
| 3765 already_signalled_(false) { | 3765 mutex_(OS::CreateMutex()), already_signalled_(false) { |
| 3766 } | 3766 } |
| 3767 | 3767 |
| 3768 | 3768 |
| 3769 MessageDispatchHelperThread::~MessageDispatchHelperThread() { | 3769 MessageDispatchHelperThread::~MessageDispatchHelperThread() { |
| 3770 delete mutex_; | 3770 delete mutex_; |
| 3771 delete sem_; | 3771 delete sem_; |
| 3772 } | 3772 } |
| 3773 | 3773 |
| 3774 | 3774 |
| 3775 void MessageDispatchHelperThread::Schedule() { | 3775 void MessageDispatchHelperThread::Schedule() { |
| 3776 { | 3776 { |
| 3777 ScopedLock lock(mutex_); | 3777 ScopedLock lock(mutex_); |
| 3778 if (already_signalled_) { | 3778 if (already_signalled_) { |
| 3779 return; | 3779 return; |
| 3780 } | 3780 } |
| 3781 already_signalled_ = true; | 3781 already_signalled_ = true; |
| 3782 } | 3782 } |
| 3783 sem_->Signal(); | 3783 sem_->Signal(); |
| 3784 } | 3784 } |
| 3785 | 3785 |
| 3786 | 3786 |
| 3787 void MessageDispatchHelperThread::Run() { | 3787 void MessageDispatchHelperThread::Run() { |
| 3788 Isolate* isolate = Isolate::Current(); | |
| 3789 while (true) { | 3788 while (true) { |
| 3790 sem_->Wait(); | 3789 sem_->Wait(); |
| 3791 { | 3790 { |
| 3792 ScopedLock lock(mutex_); | 3791 ScopedLock lock(mutex_); |
| 3793 already_signalled_ = false; | 3792 already_signalled_ = false; |
| 3794 } | 3793 } |
| 3795 { | 3794 { |
| 3796 Locker locker(reinterpret_cast<v8::Isolate*>(isolate)); | 3795 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
| 3797 isolate->debugger()->CallMessageDispatchHandler(); | 3796 isolate_->debugger()->CallMessageDispatchHandler(); |
| 3798 } | 3797 } |
| 3799 } | 3798 } |
| 3800 } | 3799 } |
| 3801 | 3800 |
| 3802 #endif // ENABLE_DEBUGGER_SUPPORT | 3801 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3803 | 3802 |
| 3804 } } // namespace v8::internal | 3803 } } // namespace v8::internal |
| OLD | NEW |