#include "gold.h"
-#include <cassert>
-
#include "workqueue.h"
namespace gold
Task_token::~Task_token()
{
- assert(this->readers_ == 0 && this->writer_ == NULL);
+ gold_assert(this->readers_ == 0 && this->writer_ == NULL);
}
bool
Task_token::is_readable() const
{
- assert(!this->is_blocker_);
+ gold_assert(!this->is_blocker_);
return this->writer_ == NULL;
}
void
Task_token::add_reader()
{
- assert(!this->is_blocker_);
- assert(this->is_readable());
+ gold_assert(!this->is_blocker_);
+ gold_assert(this->is_readable());
++this->readers_;
}
void
Task_token::remove_reader()
{
- assert(!this->is_blocker_);
- assert(this->readers_ > 0);
+ gold_assert(!this->is_blocker_);
+ gold_assert(this->readers_ > 0);
--this->readers_;
}
bool
Task_token::is_writable() const
{
- assert(!this->is_blocker_);
+ gold_assert(!this->is_blocker_);
return this->writer_ == NULL && this->readers_ == 0;
}
void
Task_token::add_writer(const Task* t)
{
- assert(!this->is_blocker_);
- assert(this->is_writable());
+ gold_assert(!this->is_blocker_);
+ gold_assert(this->is_writable());
this->writer_ = t;
}
void
Task_token::remove_writer(const Task* t)
{
- assert(!this->is_blocker_);
- assert(this->writer_ == t);
+ gold_assert(!this->is_blocker_);
+ gold_assert(this->writer_ == t);
this->writer_ = NULL;
}
bool
Task_token::has_write_lock(const Task* t)
{
- assert(!this->is_blocker_);
+ gold_assert(!this->is_blocker_);
return this->writer_ == t;
}
if (this->readers_ == 0 && this->writer_ == NULL)
this->is_blocker_ = true;
else
- assert(this->is_blocker_);
+ gold_assert(this->is_blocker_);
++this->readers_;
}
bool
Task_token::remove_blocker()
{
- assert(this->is_blocker_ && this->readers_ > 0);
+ gold_assert(this->is_blocker_ && this->readers_ > 0);
--this->readers_;
return this->readers_ == 0;
}
bool
Task_token::is_blocked() const
{
- assert(this->is_blocker_ || (this->readers_ == 0 && this->writer_ == NULL));
+ gold_assert(this->is_blocker_
+ || (this->readers_ == 0 && this->writer_ == NULL));
return this->readers_ > 0;
}
// We must increment the block count when the task is created and
// put on the queue. This object is created when the task is run,
// so we don't increment the block count here.
- assert(this->token_.is_blocked());
+ gold_assert(this->token_.is_blocked());
}
Task_block_token::~Task_block_token()
Workqueue::~Workqueue()
{
- assert(this->tasks_.empty());
- assert(this->completed_.empty());
- assert(this->running_ == 0);
+ gold_assert(this->tasks_.empty());
+ gold_assert(this->completed_.empty());
+ gold_assert(this->running_ == 0);
}
// Add a task to the queue.
{
// There had better be some tasks running, or we will
// never find a runnable task.
- assert(this->running_ > 0);
+ gold_assert(this->running_ > 0);
// We couldn't find any runnable tasks, and we
// couldn't release any locks.
// There must be something for us to wait for, or we won't
// be able to make progress.
- assert(this->running_ > 0 || !this->completed_.empty());
+ gold_assert(this->running_ > 0 || !this->completed_.empty());
if (all_blocked)
{
this->clear_completed();
while (this->cleared_blockers_ == 0)
{
- assert(this->running_ > 0);
+ gold_assert(this->running_ > 0);
this->completed_condvar_.wait();
this->clear_completed();
}
{
{
Hold_lock hl(this->completed_lock_);
- assert(this->running_ > 0);
+ gold_assert(this->running_ > 0);
--this->running_;
this->completed_.push_back(tl);
this->completed_condvar_.signal();