Skip to content

Commit

Permalink
Refactor|libdeng2: Improved API of Waitable
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 2, 2013
1 parent 1013bbc commit 3d501d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions doomsday/libdeng2/include/de/concurrency/waitable.h
Expand Up @@ -49,19 +49,19 @@ class DENG2_PUBLIC Waitable
void reset();

/// Wait until the resource becomes available. Waits indefinitely.
void wait();
void wait() const;

/// Wait for the specified period of time to secure the
/// resource. If timeout occurs, an exception is thrown.
void wait(TimeDelta const &timeOut);
void wait(TimeDelta const &timeOut) const;

/// Mark the resource as available by incrementing the
/// semaphore value.
void post();
void post() const;

private:
/// Pointer to the internal semaphore data.
QSemaphore _semaphore;
mutable QSemaphore _semaphore;
};

}
Expand Down
6 changes: 3 additions & 3 deletions doomsday/libdeng2/src/concurrency/waitable.cpp
Expand Up @@ -33,12 +33,12 @@ void Waitable::reset()
_semaphore.tryAcquire(_semaphore.available());
}

void Waitable::wait()
void Waitable::wait() const
{
wait(0.0);
}

void Waitable::wait(TimeDelta const &timeOut)
void Waitable::wait(TimeDelta const &timeOut) const
{
if(timeOut <= 0.0)
{
Expand All @@ -55,7 +55,7 @@ void Waitable::wait(TimeDelta const &timeOut)
}
}

void Waitable::post()
void Waitable::post() const
{
_semaphore.release();
}

0 comments on commit 3d501d4

Please sign in to comment.