Tweaks to OpenCLContext/OpenCLHandle defs
This commit is contained in:
parent
e07691f71d
commit
b794cace6e
2 changed files with 34 additions and 31 deletions
|
@ -1,12 +1,12 @@
|
||||||
#include "opencl_handle.h"
|
#include "opencl_handle.h"
|
||||||
|
|
||||||
std::unique_ptr<OpenCLContext> OpenCLContext::instance_ = {};
|
OpenCLContext::Ptr OpenCLContext::instance_ = {};
|
||||||
|
|
||||||
OpenCLHandle::OpenCLHandle() {
|
OpenCLContext::OpenCLHandle::OpenCLHandle() {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenCLHandle::~OpenCLHandle() { OpenCLContext::CheckRefCount(); }
|
OpenCLContext::OpenCLHandle::~OpenCLHandle() { OpenCLContext::CheckRefCount(); }
|
||||||
|
|
||||||
OpenCLContext::OpenCLContext() {
|
OpenCLContext::OpenCLContext() {
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -16,7 +16,7 @@ OpenCLContext::~OpenCLContext() {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenCLHandle::Ptr OpenCLContext::GetHandle() {
|
OpenCLContext::OpenCLHandle::Ptr OpenCLContext::GetHandle() {
|
||||||
if (!instance_) {
|
if (!instance_) {
|
||||||
// cannot use make_unique due to private constructor
|
// cannot use make_unique due to private constructor
|
||||||
instance_ = std::unique_ptr<OpenCLContext>(new OpenCLContext());
|
instance_ = std::unique_ptr<OpenCLContext>(new OpenCLContext());
|
||||||
|
|
|
@ -3,7 +3,12 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class OpenCLHandle {
|
class OpenCLContext {
|
||||||
|
public:
|
||||||
|
typedef std::shared_ptr<OpenCLContext> Ptr;
|
||||||
|
typedef std::weak_ptr<OpenCLContext> WeakPtr;
|
||||||
|
|
||||||
|
class OpenCLHandle {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<OpenCLHandle> Ptr;
|
typedef std::shared_ptr<OpenCLHandle> Ptr;
|
||||||
typedef std::weak_ptr<OpenCLHandle> WeakPtr;
|
typedef std::weak_ptr<OpenCLHandle> WeakPtr;
|
||||||
|
@ -18,17 +23,17 @@ class OpenCLHandle {
|
||||||
OpenCLHandle(OpenCLHandle &&other) = default;
|
OpenCLHandle(OpenCLHandle &&other) = default;
|
||||||
OpenCLHandle &operator=(OpenCLHandle &&other) = default;
|
OpenCLHandle &operator=(OpenCLHandle &&other) = default;
|
||||||
|
|
||||||
// TODO add functions here that allow creating/deleting/using kernel function
|
// TODO add functions here that allow creating/deleting/using kernel
|
||||||
// programs
|
// function programs
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class OpenCLContext;
|
friend class OpenCLContext;
|
||||||
|
|
||||||
OpenCLHandle();
|
OpenCLHandle();
|
||||||
};
|
|
||||||
|
|
||||||
class OpenCLContext {
|
OpenCLContext::WeakPtr opencl_ptr_;
|
||||||
public:
|
};
|
||||||
|
|
||||||
~OpenCLContext();
|
~OpenCLContext();
|
||||||
|
|
||||||
// no copy
|
// no copy
|
||||||
|
@ -42,11 +47,9 @@ class OpenCLContext {
|
||||||
OpenCLHandle::Ptr GetHandle();
|
OpenCLHandle::Ptr GetHandle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class OpenCLHandle;
|
|
||||||
|
|
||||||
OpenCLContext();
|
OpenCLContext();
|
||||||
|
|
||||||
static std::unique_ptr<OpenCLContext> instance_;
|
static Ptr instance_;
|
||||||
OpenCLHandle::WeakPtr weak_handle_;
|
OpenCLHandle::WeakPtr weak_handle_;
|
||||||
|
|
||||||
static void CheckRefCount();
|
static void CheckRefCount();
|
||||||
|
|
Loading…
Reference in a new issue