http://stxxl.sourceforge.net
<dementiev@mpi-sb.mpg.de>
<beckmann@cs.uni-frankfurt.de>
http://www.boost.org/LICENSE_1_0.txt
#include <stxxl/bits/common/mutex.h>
#include <stxxl/bits/common/onoff_switch.h>
#include <stxxl/bits/io/request_with_waiters.h>
#include <stxxl/bits/parallel.h>
#include <algorithm>
#include <functional>
STXXL_BEGIN_NAMESPACE
bool request_with_waiters::add_waiter(onoff_switch* sw)
{
scoped_mutex_lock lock(waiters_mutex);
if (poll())
{
return true;
}
waiters.insert(sw);
return false;
}
void request_with_waiters::delete_waiter(onoff_switch* sw)
{
scoped_mutex_lock lock(waiters_mutex);
waiters.erase(sw);
}
void request_with_waiters::notify_waiters()
{
scoped_mutex_lock lock(waiters_mutex);
std::for_each(waiters.begin(),
waiters.end(),
std::mem_fun(&onoff_switch::on)
_STXXL_FORCE_SEQUENTIAL);
}
STXXL_END_NAMESPACE