[CP] [OPT] thread stack lock
This commit is contained in:
@ -156,12 +156,12 @@ void StackMgr::insert(ObStackHeader *header)
|
|||||||
{
|
{
|
||||||
if (header != nullptr) {
|
if (header != nullptr) {
|
||||||
abort_unless(header->check_magic());
|
abort_unless(header->check_magic());
|
||||||
mutex_.lock();
|
rwlock_.wrlock(common::ObLatchIds::DEFAULT_SPIN_RWLOCK);
|
||||||
header->prev_ = &dummy_;
|
header->prev_ = &dummy_;
|
||||||
header->next_ = dummy_.next_;
|
header->next_ = dummy_.next_;
|
||||||
dummy_.next_->prev_ = header;
|
dummy_.next_->prev_ = header;
|
||||||
dummy_.next_ = header;
|
dummy_.next_ = header;
|
||||||
mutex_.unlock();
|
rwlock_.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,11 +169,11 @@ void StackMgr::erase(ObStackHeader *header)
|
|||||||
{
|
{
|
||||||
if (header != nullptr) {
|
if (header != nullptr) {
|
||||||
abort_unless(header->check_magic());
|
abort_unless(header->check_magic());
|
||||||
mutex_.lock();
|
rwlock_.wrlock(common::ObLatchIds::DEFAULT_SPIN_RWLOCK);
|
||||||
header->prev_->next_ = header->next_;
|
header->prev_->next_ = header->next_;
|
||||||
header->next_->prev_ = header->prev_;
|
header->next_->prev_ = header->prev_;
|
||||||
header->prev_ = header->next_ = header;
|
header->prev_ = header->next_ = header;
|
||||||
mutex_.unlock();
|
rwlock_.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "lib/lock/ob_mutex.h"
|
#include "lib/lock/ob_latch.h"
|
||||||
|
|
||||||
namespace oceanbase {
|
namespace oceanbase {
|
||||||
namespace lib {
|
namespace lib {
|
||||||
@ -62,10 +62,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
Guard(StackMgr& mgr) : mgr_(mgr), cur_(nullptr)
|
Guard(StackMgr& mgr) : mgr_(mgr), cur_(nullptr)
|
||||||
{
|
{
|
||||||
mgr_.mutex_.lock();
|
mgr_.rwlock_.rdlock(common::ObLatchIds::DEFAULT_SPIN_RWLOCK);
|
||||||
cur_ = mgr_.dummy_.next_;
|
cur_ = mgr_.dummy_.next_;
|
||||||
}
|
}
|
||||||
~Guard() { mgr_.mutex_.unlock(); }
|
~Guard() { mgr_.rwlock_.unlock(); }
|
||||||
ObStackHeader* operator*() { return (cur_ == &(mgr_.dummy_)) ? nullptr : cur_; }
|
ObStackHeader* operator*() { return (cur_ == &(mgr_.dummy_)) ? nullptr : cur_; }
|
||||||
ObStackHeader* next()
|
ObStackHeader* next()
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ private:
|
|||||||
ObStackHeader *begin() { return dummy_.next_; }
|
ObStackHeader *begin() { return dummy_.next_; }
|
||||||
ObStackHeader *end() { return &dummy_; }
|
ObStackHeader *end() { return &dummy_; }
|
||||||
private:
|
private:
|
||||||
lib::ObMutex mutex_;
|
common::ObLatch rwlock_;
|
||||||
ObStackHeader dummy_;
|
ObStackHeader dummy_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user