kodi
SingleLock.h
1 /*
2  * Copyright (c) 2002 Frodo
3  * Portions Copyright (c) by the authors of ffmpeg and xvid
4  * Copyright (C) 2002-2018 Team Kodi
5  * This file is part of Kodi - https://kodi.tv
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  * See LICENSES/README.md for more information.
9  */
10 
11 #pragma once
12 
13 #include "threads/CriticalSection.h"
14 
15 #include <mutex>
16 
26 {
27  CCriticalSection& sec;
28  unsigned int count;
29 public:
30  inline explicit CSingleExit(CCriticalSection& cs) : sec(cs), count(cs.exit()) { }
31  inline ~CSingleExit() { sec.restore(count); }
32 };
This implements a "guard" pattern for exiting all locks currently being held by the current thread an...
Definition: SingleLock.h:25