3 * Copyright 2007 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef INCLUDED_MBI_RUNTIME_LOCK_H
23 #define INCLUDED_MBI_RUNTIME_LOCK_H
25 #include <mb_runtime.h>
26 #include <mb_mblock_impl.h>
27 #include <boost/utility.hpp>
30 * \brief acquire and release big runtime lock
32 * As an alternative to:
39 * you can use a single instance of the mbi_runtime_lock class:
42 * mbi_runtime_lock l(rt);
46 * This has the advantage that rt->unlock() will be called automatically
47 * when an exception is thrown.
50 class mbi_runtime_lock : boost::noncopyable {
51 mb_runtime_base *d_rt;
53 mbi_runtime_lock(mb_runtime_base *rt) : d_rt(rt) { d_rt->lock(); }
54 mbi_runtime_lock(mb_mblock_impl *mi) : d_rt(mi->runtime()) { d_rt->lock(); }
55 mbi_runtime_lock(mb_mblock *mb) : d_rt(mb->impl()->runtime()) { d_rt->lock(); }
56 ~mbi_runtime_lock(void) { d_rt->unlock(); }
60 #endif /* INCLUDED_MBI_RUNTIME_LOCK_H */