Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| DeviceGuard.cpp |
|
||||
| |
|
||||
| An abstract interface for acquiring and releasing |
|
||||
| a guard on a device, serving as a foundation for |
|
||||
| implementing device-specific synchronization mechanisms |
|
||||
| |
|
||||
| Evan Mulawski 09 May 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "DeviceGuard.h"
|
||||
|
||||
DeviceGuard::DeviceGuard()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceGuard::~DeviceGuard()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| DeviceGuard.h |
|
||||
| |
|
||||
| An abstract interface for acquiring and releasing |
|
||||
| a guard on a device, serving as a foundation for |
|
||||
| implementing device-specific synchronization mechanisms |
|
||||
| |
|
||||
| Evan Mulawski 09 May 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class DeviceGuard
|
||||
{
|
||||
public:
|
||||
DeviceGuard();
|
||||
virtual ~DeviceGuard();
|
||||
|
||||
virtual void Acquire() = 0;
|
||||
virtual void Release() = 0;
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| DeviceGuardLock.cpp |
|
||||
| |
|
||||
| Represents a lock for a device guard, ensuring |
|
||||
| exclusive access to a device when acquired and |
|
||||
| releasing it when destroyed |
|
||||
| |
|
||||
| Evan Mulawski 09 May 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "DeviceGuardLock.h"
|
||||
|
||||
DeviceGuardLock::DeviceGuardLock(DeviceGuard& guard_ref) : guard(guard_ref)
|
||||
{
|
||||
guard.Acquire();
|
||||
}
|
||||
|
||||
DeviceGuardLock::~DeviceGuardLock()
|
||||
{
|
||||
guard.Release();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| DeviceGuardLock.h |
|
||||
| |
|
||||
| Represents a lock for a device guard, ensuring |
|
||||
| exclusive access to a device when acquired and |
|
||||
| releasing it when destroyed |
|
||||
| |
|
||||
| Evan Mulawski 09 May 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DeviceGuard.h"
|
||||
|
||||
class DeviceGuardLock
|
||||
{
|
||||
public:
|
||||
DeviceGuardLock(DeviceGuard& guard_ref);
|
||||
~DeviceGuardLock();
|
||||
|
||||
private:
|
||||
DeviceGuard& guard;
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| DeviceGuardManager.cpp |
|
||||
| |
|
||||
| Responsible for managing a DeviceGuard implementation, |
|
||||
| allowing clients to wait for exclusive access to a |
|
||||
| device using the DeviceGuardLock it provides |
|
||||
| |
|
||||
| Evan Mulawski 09 May 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "DeviceGuardManager.h"
|
||||
|
||||
DeviceGuardManager::DeviceGuardManager(DeviceGuard* guard_ptr) : guard(guard_ptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceGuardManager::~DeviceGuardManager()
|
||||
{
|
||||
delete guard;
|
||||
}
|
||||
|
||||
DeviceGuardLock DeviceGuardManager::AwaitExclusiveAccess()
|
||||
{
|
||||
return DeviceGuardLock(*guard);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| DeviceGuardManager.h |
|
||||
| |
|
||||
| Responsible for managing a DeviceGuard implementation, |
|
||||
| allowing clients to wait for exclusive access to a |
|
||||
| device using the DeviceGuardLock it provides |
|
||||
| |
|
||||
| Evan Mulawski 09 May 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DeviceGuardLock.h"
|
||||
|
||||
class DeviceGuardManager
|
||||
{
|
||||
public:
|
||||
DeviceGuardManager(DeviceGuard* guard_ptr);
|
||||
~DeviceGuardManager();
|
||||
|
||||
DeviceGuardLock AwaitExclusiveAccess();
|
||||
|
||||
private:
|
||||
DeviceGuard* guard;
|
||||
};
|
||||
Reference in New Issue
Block a user