https://github.com/halide/Halide
Raw File
Tip revision: baaf45c5fbe8f08a45aefdff7d09ec2f5c0cfdef authored by Steven Johnson on 22 December 2018, 00:21:50 UTC
minimal fixes
Tip revision: baaf45c
scoped_mutex_lock.h
#ifndef HALIDE_RUNTIME_SCOPED_MUTEX_LOCK_H
#define HALIDE_RUNTIME_SCOPED_MUTEX_LOCK_H

#include "HalideRuntime.h"

namespace Halide { namespace Runtime { namespace Internal {

// An RAII mutex locking operation
struct ScopedMutexLock {
    halide_mutex *mutex;

    ScopedMutexLock(halide_mutex *mutex) __attribute__((always_inline)) : mutex(mutex) {
        halide_mutex_lock(mutex);
    }

    ~ScopedMutexLock() __attribute__((always_inline)) {
        halide_mutex_unlock(mutex);
    }
};

}}} // namespace Halide::Runtime::Internal

#endif
back to top