Commit b725cbf7 authored by Roman Donchenko's avatar Roman Donchenko Committed by OpenCV Buildbot

Merge pull request #986 from pengx17:2.4_initiated_context

parents 5bb6d366 5fd724b5
...@@ -134,6 +134,9 @@ namespace cv ...@@ -134,6 +134,9 @@ namespace cv
//getDevice also need to be called before this function //getDevice also need to be called before this function
CV_EXPORTS void setDeviceEx(Info &oclinfo, void *ctx, void *qu, int devnum = 0); CV_EXPORTS void setDeviceEx(Info &oclinfo, void *ctx, void *qu, int devnum = 0);
//returns true when global OpenCL context is initialized
CV_EXPORTS bool initialized();
//////////////////////////////// Error handling //////////////////////// //////////////////////////////// Error handling ////////////////////////
CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func); CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func);
...@@ -144,7 +147,7 @@ namespace cv ...@@ -144,7 +147,7 @@ namespace cv
protected: protected:
Context(); Context();
friend class auto_ptr<Context>; friend class auto_ptr<Context>;
friend bool initialized();
private: private:
static auto_ptr<Context> clCxt; static auto_ptr<Context> clCxt;
static int val; static int val;
......
...@@ -917,6 +917,14 @@ namespace cv ...@@ -917,6 +917,14 @@ namespace cv
int Context::val = 0; int Context::val = 0;
static Mutex cs; static Mutex cs;
static volatile int context_tear_down = 0; static volatile int context_tear_down = 0;
bool initialized()
{
return *((volatile int*)&Context::val) != 0 &&
Context::clCxt->impl->clCmdQueue != NULL&&
Context::clCxt->impl->oclcontext != NULL;
}
Context* Context::getContext() Context* Context::getContext()
{ {
if(*((volatile int*)&val) != 1) if(*((volatile int*)&val) != 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment