1 /*
2  * %kadu copyright begin%
3  * Copyright 2013, 2014 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com)
4  * %kadu copyright end%
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "change-notifier-lock.h"
21 
22 #include "misc/change-notifier.h"
23 
ChangeNotifierLock(ChangeNotifier & notifier,Mode mode)24 ChangeNotifierLock::ChangeNotifierLock(ChangeNotifier &notifier, Mode mode)
25 		: m_notifier(notifier), m_notifierMode{mode}
26 {
27 	m_notifier.block();
28 }
29 
~ChangeNotifierLock()30 ChangeNotifierLock::~ChangeNotifierLock()
31 {
32 	if (ModeForget == m_notifierMode)
33 		m_notifier.forget();
34 	m_notifier.unblock();
35 }
36 
setMode(Mode mode)37 void ChangeNotifierLock::setMode(Mode mode)
38 {
39 	m_notifierMode = mode;
40 }
41