mirror of https://github.com/AxioDL/boo.git
Merge pull request #20 from lioncash/move
BooObject: Make ObjToken interface noexcept where applicable
This commit is contained in:
commit
8114361966
|
@ -1,8 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include "nxstl/mutex"
|
||||
|
||||
namespace boo {
|
||||
|
||||
|
@ -13,11 +11,10 @@ protected:
|
|||
virtual ~IObj() = default;
|
||||
|
||||
public:
|
||||
virtual std::unique_lock<std::recursive_mutex> destructorLock() = 0;
|
||||
void increment() { m_refCount++; }
|
||||
void decrement() {
|
||||
if (m_refCount.fetch_sub(1) == 1) {
|
||||
auto lk = destructorLock();
|
||||
void increment() noexcept { m_refCount.fetch_add(1, std::memory_order_relaxed); }
|
||||
void decrement() noexcept {
|
||||
if (m_refCount.fetch_sub(1, std::memory_order_release) == 1) {
|
||||
std::atomic_thread_fence(std::memory_order_acquire);
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
@ -28,17 +25,17 @@ class ObjToken {
|
|||
SubCls* m_obj = nullptr;
|
||||
|
||||
public:
|
||||
ObjToken() = default;
|
||||
ObjToken(SubCls* obj) : m_obj(obj) {
|
||||
ObjToken() noexcept = default;
|
||||
ObjToken(SubCls* obj) noexcept : m_obj(obj) {
|
||||
if (m_obj)
|
||||
m_obj->increment();
|
||||
}
|
||||
ObjToken(const ObjToken& other) : m_obj(other.m_obj) {
|
||||
ObjToken(const ObjToken& other) noexcept : m_obj(other.m_obj) {
|
||||
if (m_obj)
|
||||
m_obj->increment();
|
||||
}
|
||||
ObjToken(ObjToken&& other) : m_obj(other.m_obj) { other.m_obj = nullptr; }
|
||||
ObjToken& operator=(SubCls* obj) {
|
||||
ObjToken(ObjToken&& other) noexcept : m_obj(other.m_obj) { other.m_obj = nullptr; }
|
||||
ObjToken& operator=(SubCls* obj) noexcept {
|
||||
if (m_obj)
|
||||
m_obj->decrement();
|
||||
m_obj = obj;
|
||||
|
@ -46,7 +43,7 @@ public:
|
|||
m_obj->increment();
|
||||
return *this;
|
||||
}
|
||||
ObjToken& operator=(const ObjToken& other) {
|
||||
ObjToken& operator=(const ObjToken& other) noexcept {
|
||||
if (m_obj)
|
||||
m_obj->decrement();
|
||||
m_obj = other.m_obj;
|
||||
|
@ -54,26 +51,26 @@ public:
|
|||
m_obj->increment();
|
||||
return *this;
|
||||
}
|
||||
ObjToken& operator=(ObjToken&& other) {
|
||||
ObjToken& operator=(ObjToken&& other) noexcept {
|
||||
if (m_obj)
|
||||
m_obj->decrement();
|
||||
m_obj = other.m_obj;
|
||||
other.m_obj = nullptr;
|
||||
return *this;
|
||||
}
|
||||
~ObjToken() {
|
||||
~ObjToken() noexcept {
|
||||
if (m_obj)
|
||||
m_obj->decrement();
|
||||
}
|
||||
SubCls* get() const { return m_obj; }
|
||||
SubCls* operator->() const { return m_obj; }
|
||||
SubCls& operator*() const { return *m_obj; }
|
||||
SubCls* get() const noexcept { return m_obj; }
|
||||
SubCls* operator->() const noexcept { return m_obj; }
|
||||
SubCls& operator*() const noexcept { return *m_obj; }
|
||||
template <class T>
|
||||
T* cast() const {
|
||||
T* cast() const noexcept {
|
||||
return static_cast<T*>(m_obj);
|
||||
}
|
||||
operator bool() const { return m_obj != nullptr; }
|
||||
void reset() {
|
||||
operator bool() const noexcept { return m_obj != nullptr; }
|
||||
void reset() noexcept {
|
||||
if (m_obj)
|
||||
m_obj->decrement();
|
||||
m_obj = nullptr;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "AudioVoiceEngine.hpp"
|
||||
#include "logvisor/logvisor.hpp"
|
||||
#include "boo/IApplication.hpp"
|
||||
#include "../CFPointer.hpp"
|
||||
|
||||
|
@ -7,8 +6,7 @@
|
|||
#include <CoreMIDI/CoreMIDI.h>
|
||||
#include <CoreAudio/HostTime.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <logvisor/logvisor.hpp>
|
||||
|
||||
namespace boo {
|
||||
static logvisor::Module Log("boo::AQS");
|
||||
|
|
|
@ -21,9 +21,6 @@ AudioSubmix*& AudioSubmix::_getHeadPtr(BaseAudioVoiceEngine* head) { return head
|
|||
std::unique_lock<std::recursive_mutex> AudioSubmix::_getHeadLock(BaseAudioVoiceEngine* head) {
|
||||
return std::unique_lock<std::recursive_mutex>{head->m_dataMutex};
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> AudioSubmix::destructorLock() {
|
||||
return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex};
|
||||
}
|
||||
|
||||
bool AudioSubmix::_isDirectDependencyOf(AudioSubmix* send) { return m_sendGains.find(send) != m_sendGains.cend(); }
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "boo/audiodev/IAudioSubmix.hpp"
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include "Common.hpp"
|
||||
|
||||
#if __SSE__
|
||||
|
@ -80,7 +81,6 @@ class AudioSubmix : public ListNode<AudioSubmix, BaseAudioVoiceEngine*, IAudioSu
|
|||
public:
|
||||
static AudioSubmix*& _getHeadPtr(BaseAudioVoiceEngine* head);
|
||||
static std::unique_lock<std::recursive_mutex> _getHeadLock(BaseAudioVoiceEngine* head);
|
||||
std::unique_lock<std::recursive_mutex> destructorLock() override;
|
||||
|
||||
AudioSubmix(BaseAudioVoiceEngine& root, IAudioSubmixCallback* cb, int busId, bool mainOut);
|
||||
~AudioSubmix() override;
|
||||
|
|
|
@ -18,9 +18,6 @@ AudioVoice*& AudioVoice::_getHeadPtr(BaseAudioVoiceEngine* head) { return head->
|
|||
std::unique_lock<std::recursive_mutex> AudioVoice::_getHeadLock(BaseAudioVoiceEngine* head) {
|
||||
return std::unique_lock<std::recursive_mutex>{head->m_dataMutex};
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> AudioVoice::destructorLock() {
|
||||
return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex};
|
||||
}
|
||||
|
||||
void AudioVoice::_setPitchRatio(double ratio, bool slew) {
|
||||
if (m_dynamicRate) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <soxr.h>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
#include "boo/audiodev/IAudioVoice.hpp"
|
||||
#include "AudioMatrix.hpp"
|
||||
#include "Common.hpp"
|
||||
#include "AudioVoiceEngine.hpp"
|
||||
#include "Common.hpp"
|
||||
|
||||
struct AudioUnitVoiceEngine;
|
||||
struct VSTVoiceEngine;
|
||||
|
@ -64,7 +64,6 @@ protected:
|
|||
public:
|
||||
static AudioVoice*& _getHeadPtr(BaseAudioVoiceEngine* head);
|
||||
static std::unique_lock<std::recursive_mutex> _getHeadLock(BaseAudioVoiceEngine* head);
|
||||
std::unique_lock<std::recursive_mutex> destructorLock() override;
|
||||
|
||||
~AudioVoice() override;
|
||||
void resetSampleRate(double sampleRate) override;
|
||||
|
|
|
@ -3,14 +3,15 @@
|
|||
/* Private header for managing shader data
|
||||
* binding lifetimes through rendering cycle */
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <cassert>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
#include "boo/graphicsdev/IGraphicsCommandQueue.hpp"
|
||||
#include "../Common.hpp"
|
||||
|
@ -63,9 +64,6 @@ struct BaseGraphicsData : ListNode<BaseGraphicsData, GraphicsDataFactoryHead*> {
|
|||
auto* head = getHead<T>();
|
||||
return head ? head->countForward() : 0;
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> destructorLock() override {
|
||||
return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex};
|
||||
}
|
||||
|
||||
explicit BaseGraphicsData(GraphicsDataFactoryHead& head __BooTraceArgs)
|
||||
: ListNode<BaseGraphicsData, GraphicsDataFactoryHead*>(&head) __BooTraceInitializer {}
|
||||
|
@ -131,9 +129,6 @@ struct BaseGraphicsPool : ListNode<BaseGraphicsPool, GraphicsDataFactoryHead*> {
|
|||
auto* head = getHead<T>();
|
||||
return head ? head->countForward() : 0;
|
||||
}
|
||||
std::unique_lock<std::recursive_mutex> destructorLock() override {
|
||||
return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex};
|
||||
}
|
||||
|
||||
explicit BaseGraphicsPool(GraphicsDataFactoryHead& head __BooTraceArgs)
|
||||
: ListNode<BaseGraphicsPool, GraphicsDataFactoryHead*>(&head) __BooTraceInitializer {}
|
||||
|
@ -158,10 +153,6 @@ struct GraphicsDataNode : ListNode<GraphicsDataNode<NodeCls, DataCls>, ObjToken<
|
|||
return std::unique_lock<std::recursive_mutex>{head->m_head->m_dataMutex};
|
||||
}
|
||||
|
||||
std::unique_lock<std::recursive_mutex> destructorLock() override {
|
||||
return std::unique_lock<std::recursive_mutex>{base::m_head->m_head->m_dataMutex};
|
||||
}
|
||||
|
||||
explicit GraphicsDataNode(const ObjToken<DataCls>& data)
|
||||
: ListNode<GraphicsDataNode<NodeCls, DataCls>, ObjToken<DataCls>, NodeCls>(data) {}
|
||||
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
#include "../win/Win32Common.hpp"
|
||||
#include "logvisor/logvisor.hpp"
|
||||
#include "boo/graphicsdev/D3D.hpp"
|
||||
#include "boo/IGraphicsContext.hpp"
|
||||
#include "Common.hpp"
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <d3dcompiler.h>
|
||||
#include <comdef.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <forward_list>
|
||||
#include "xxhash/xxhash.h"
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <d3dcompiler.h>
|
||||
#include <comdef.h>
|
||||
|
||||
#include <logvisor/logvisor.hpp>
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
|
|
@ -2,22 +2,22 @@
|
|||
#include "boo/graphicsdev/glew.h"
|
||||
#include "boo/IApplication.hpp"
|
||||
#include "Common.hpp"
|
||||
#include <thread>
|
||||
#include <condition_variable>
|
||||
|
||||
#include <array>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include "xxhash/xxhash.h"
|
||||
#include "glslang/Public/ShaderLang.h"
|
||||
#include "glslang/Include/Types.h"
|
||||
#include "StandAlone/ResourceLimits.h"
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
#include <glslang/Include/Types.h>
|
||||
#include <StandAlone/ResourceLimits.h>
|
||||
|
||||
#include <logvisor/logvisor.hpp>
|
||||
|
||||
#if _WIN32
|
||||
#include "../win/WinCommon.hpp"
|
||||
#endif
|
||||
|
||||
#include "logvisor/logvisor.hpp"
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
|
|
|
@ -1060,9 +1060,6 @@ struct VulkanDescriptorPool : ListNode<VulkanDescriptorPool, VulkanDataFactoryIm
|
|||
|
||||
~VulkanDescriptorPool() { vk::DestroyDescriptorPool(m_head->m_ctx->m_dev, m_descPool, nullptr); }
|
||||
|
||||
std::unique_lock<std::recursive_mutex> destructorLock() override {
|
||||
return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex};
|
||||
}
|
||||
static std::unique_lock<std::recursive_mutex> _getHeadLock(VulkanDataFactoryImpl* factory) {
|
||||
return std::unique_lock<std::recursive_mutex>{factory->m_dataMutex};
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
#include "IHIDDevice.hpp"
|
||||
#include "boo/inputdev/DeviceToken.hpp"
|
||||
#include "boo/inputdev/DeviceBase.hpp"
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include <algorithm>
|
||||
#include <condition_variable>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
#include "boo/graphicsdev/Metal.hpp"
|
||||
#include "CocoaCommon.hpp"
|
||||
|
||||
#include "boo/IApplication.hpp"
|
||||
#include "boo/IGraphicsContext.hpp"
|
||||
#include "boo/IWindow.hpp"
|
||||
#include "boo/audiodev/IAudioVoiceEngine.hpp"
|
||||
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <CoreVideo/CVDisplayLink.h>
|
||||
#include "boo/IApplication.hpp"
|
||||
#include "boo/IWindow.hpp"
|
||||
#include "boo/IGraphicsContext.hpp"
|
||||
#include "boo/audiodev/IAudioVoiceEngine.hpp"
|
||||
#include "logvisor/logvisor.hpp"
|
||||
|
||||
#include <logvisor/logvisor.hpp>
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
#error ARC Required
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#include "boo/IApplication.hpp"
|
||||
#include "logvisor/logvisor.hpp"
|
||||
#include "nxstl/thread"
|
||||
#include "nxstl/condition_variable"
|
||||
#include "nxstl/mutex"
|
||||
|
||||
#include "boo/IApplication.hpp"
|
||||
#include "boo/graphicsdev/NX.hpp"
|
||||
#include <limits.h>
|
||||
|
||||
#include <climits>
|
||||
|
||||
#include <logvisor/logvisor.hpp>
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ PFN_GetScaleFactorForMonitor MyGetScaleFactorForMonitor = nullptr;
|
|||
#include "boo/graphicsdev/Vulkan.hpp"
|
||||
#endif
|
||||
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
DWORD g_mainThreadId = 0;
|
||||
std::mutex g_nwmt;
|
||||
std::condition_variable g_nwcv;
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
#endif
|
||||
#include "boo/graphicsdev/GL.hpp"
|
||||
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
extern DWORD g_mainThreadId;
|
||||
extern std::mutex g_nwmt;
|
||||
extern std::condition_variable g_nwcv;
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
#include <X11/extensions/XInput2.h>
|
||||
#include <GL/glx.h>
|
||||
#include <GL/glxext.h>
|
||||
#include <locale>
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
DBusConnection* RegisterDBus(const char* appName, bool& isFirst);
|
||||
|
||||
#include <signal.h>
|
||||
#include <condition_variable>
|
||||
#include <csignal>
|
||||
#include <locale>
|
||||
#include <mutex>
|
||||
#include <sys/param.h>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
#include "XlibCommon.hpp"
|
||||
#include <X11/cursorfont.h>
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
#include <X11/Xlib-xcb.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <GL/glx.h>
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
#include <X11/extensions/XInput2.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include "logvisor/logvisor.hpp"
|
||||
#include <logvisor/logvisor.hpp>
|
||||
|
||||
#include "XlibCommon.hpp"
|
||||
|
||||
|
|
Loading…
Reference in New Issue