OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 // the calling thread on entrance. | 501 // the calling thread on entrance. |
502 virtual int Unlock() = 0; | 502 virtual int Unlock() = 0; |
503 | 503 |
504 // Tries to lock the given mutex. Returns whether the mutex was | 504 // Tries to lock the given mutex. Returns whether the mutex was |
505 // successfully locked. | 505 // successfully locked. |
506 virtual bool TryLock() = 0; | 506 virtual bool TryLock() = 0; |
507 }; | 507 }; |
508 | 508 |
509 | 509 |
510 // ---------------------------------------------------------------------------- | 510 // ---------------------------------------------------------------------------- |
511 // ScopedLock/ScopedUnlock | 511 // ScopedLock |
512 // | 512 // |
513 // Stack-allocated ScopedLocks/ScopedUnlocks provide block-scoped | 513 // Stack-allocated ScopedLocks provide block-scoped locking and |
514 // locking and unlocking of a mutex. | 514 // unlocking of a mutex. |
515 class ScopedLock { | 515 class ScopedLock { |
516 public: | 516 public: |
517 explicit ScopedLock(Mutex* mutex): mutex_(mutex) { | 517 explicit ScopedLock(Mutex* mutex): mutex_(mutex) { |
518 ASSERT(mutex_ != NULL); | 518 ASSERT(mutex_ != NULL); |
519 mutex_->Lock(); | 519 mutex_->Lock(); |
520 } | 520 } |
521 ~ScopedLock() { | 521 ~ScopedLock() { |
522 mutex_->Unlock(); | 522 mutex_->Unlock(); |
523 } | 523 } |
524 | 524 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 int samples_taken_; // Counts stack samples taken. | 684 int samples_taken_; // Counts stack samples taken. |
685 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 685 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
686 }; | 686 }; |
687 | 687 |
688 | 688 |
689 #endif // ENABLE_LOGGING_AND_PROFILING | 689 #endif // ENABLE_LOGGING_AND_PROFILING |
690 | 690 |
691 } } // namespace v8::internal | 691 } } // namespace v8::internal |
692 | 692 |
693 #endif // V8_PLATFORM_H_ | 693 #endif // V8_PLATFORM_H_ |
OLD | NEW |