template <typename F>
void setCallback(F func) {
{
- std::lock_guard<std::mutex> lock(mutex_);
+ std::lock_guard<decltype(mutex_)> lock(mutex_);
if (callback_) {
throw std::logic_error("setCallback called twice");
void fulfil(Try<T>&& t) {
{
- std::lock_guard<std::mutex> lock(mutex_);
+ std::lock_guard<decltype(mutex_)> lock(mutex_);
if (ready()) {
throw std::logic_error("fulfil called twice");
}
void deactivate() {
- std::lock_guard<std::mutex> lock(mutex_);
+ std::lock_guard<decltype(mutex_)> lock(mutex_);
active_ = false;
}
void activate() {
{
- std::lock_guard<std::mutex> lock(mutex_);
+ std::lock_guard<decltype(mutex_)> lock(mutex_);
active_ = true;
}
maybeCallback();
private:
void maybeCallback() {
- std::lock_guard<std::mutex> lock(mutex_);
+ std::lock_guard<decltype(mutex_)> lock(mutex_);
if (!calledBack_ &&
value_ && callback_ && active_) {
// TODO we should probably try/catch here
void detachOne() {
bool shouldDelete;
{
- std::lock_guard<std::mutex> lock(mutex_);
+ std::lock_guard<decltype(mutex_)> lock(mutex_);
detached_++;
assert(detached_ == 1 || detached_ == 2);
shouldDelete = (detached_ == 2);
// this lock isn't meant to protect all accesses to members, only the ones
// that need to be threadsafe: the act of setting value_ and callback_, and
// seeing if they are set and whether we should then continue.
- std::mutex mutex_;
+ std::recursive_mutex mutex_;
};
template <typename... Ts>