Commit f0f4a4e5 authored by chenzhangyi01's avatar chenzhangyi01

cherry pick from svn r35222

Change-Id: Id0ffe967ffba5097536892f75ba7eb2c42a952b9
parent c9627fc4
...@@ -653,7 +653,7 @@ int butex_wait(void* arg, int expected_value, const timespec* abstime) { ...@@ -653,7 +653,7 @@ int butex_wait(void* arg, int expected_value, const timespec* abstime) {
} }
} }
#ifdef SHOW_BTHREAD_BUTEX_WAITER_COUNT_IN_VARS #ifdef SHOW_BTHREAD_BUTEX_WAITER_COUNT_IN_VARS
bvar::Adder<int64_t>* num_waiters = *butex_waiter_count(); bvar::Adder<int64_t>& num_waiters = butex_waiter_count();
num_waiters << 1; num_waiters << 1;
#endif #endif
......
...@@ -27,8 +27,13 @@ namespace bthread { ...@@ -27,8 +27,13 @@ namespace bthread {
// Park idle workers. // Park idle workers.
class BAIDU_CACHELINE_ALIGNMENT ParkingLot { class BAIDU_CACHELINE_ALIGNMENT ParkingLot {
public: public:
struct State { class State {
public:
State(): val(0) {}
bool stopped() const { return val & 1; } bool stopped() const { return val & 1; }
private:
friend class ParkingLot;
State(int val) : val(val) {}
int val; int val;
}; };
...@@ -43,8 +48,7 @@ public: ...@@ -43,8 +48,7 @@ public:
// Get a state for later wait(). // Get a state for later wait().
State get_state() { State get_state() {
const State st = {_pending_signal.load(base::memory_order_acquire)}; return _pending_signal.load(base::memory_order_acquire);
return st;
} }
// Wait for tasks. // Wait for tasks.
......
...@@ -174,9 +174,6 @@ void TaskGroup::run_main_task() { ...@@ -174,9 +174,6 @@ void TaskGroup::run_main_task() {
TaskGroup* dummy = this; TaskGroup* dummy = this;
bthread_t tid; bthread_t tid;
#ifndef BTHREAD_DONT_SAVE_PARKING_STATE
_last_pl_state = _pl->get_state();
#endif
while (wait_task(&tid)) { while (wait_task(&tid)) {
TaskGroup::sched_to(&dummy, tid); TaskGroup::sched_to(&dummy, tid);
DCHECK_EQ(this, dummy); DCHECK_EQ(this, dummy);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment