提交 d8366a67 编写于 作者: L liaogang

fix bug on thread barrier

上级 b2d65384
......@@ -254,4 +254,10 @@ int main(int argc, char** argv) {
return RUN_ALL_TESTS();
}
#else
int main(int argc, char const* argv[]) {
return 0;
}
#endif
......@@ -49,7 +49,7 @@ void Semaphore::post() {
class SpinLockPrivate {
public:
SpinLockPrivate(): lock_(0) {}
SpinLockPrivate(): lock_(OS_SPINLOCK_INIT) {}
OSSpinLock lock_;
char padding_[64 - sizeof(OSSpinLock)]; // Padding to cache line size
......@@ -92,7 +92,7 @@ public:
inline bool wait() {
pthread_mutex_lock(&mutex);
++count;
if (count > tripCount) {
if (count >= tripCount) {
count = 0;
pthread_cond_broadcast(&cond);
pthread_mutex_unlock(&mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册