Kaydet (Commit) 51a01d79 authored tarafından Tor Lillqvist's avatar Tor Lillqvist Kaydeden (comit) Michael Meeks

Try to make the background OpenCL compilation conditional at run-time

Change-Id: I2366465f4e786f905c32b17a15c16486c4c21d38
üst 94544378
......@@ -18,6 +18,7 @@
*/
#include "formulacell.hxx"
#include "grouptokenconverter.hxx"
#include "compiler.hxx"
#include "document.hxx"
......@@ -414,6 +415,9 @@ ScFormulaCellGroup::ScFormulaCellGroup() :
mbSubTotal(false),
meCalcState(sc::GroupCalcEnabled)
{
static bool bBackgroundCompilation = getenv("SC_BACKGROUND_COMPILATION") != NULL;
if (bBackgroundCompilation)
{
if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
{
osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex());
......@@ -424,6 +428,7 @@ ScFormulaCellGroup::ScFormulaCellGroup() :
mxCLKernelThread->launch();
}
}
}
}
ScFormulaCellGroup::~ScFormulaCellGroup()
......@@ -431,7 +436,7 @@ ScFormulaCellGroup::~ScFormulaCellGroup()
if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
{
osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex());
if (--mnCount == 0)
if (--mnCount == 0 && mxCLKernelThread.is())
{
assert(mxCLKernelThread.is());
mxCLKernelThread->finish();
......@@ -3477,17 +3482,35 @@ bool ScFormulaCell::InterpretFormulaGroup()
if (mxGroup->mbInvariant && false)
return InterpretInvariantFormulaGroup();
ScTokenArray aDummy;
if (mxGroup->meCalcState == sc::GroupCalcEnabled)
{
ScTokenArray aCode;
ScAddress aTopPos = aPos;
aTopPos.SetRow(mxGroup->mpTopCell->aPos.Row());
ScGroupTokenConverter aConverter(aCode, *pDocument, *this, mxGroup->mpTopCell->aPos);
if (!aConverter.convert(*pCode))
{
mxGroup->meCalcState = sc::GroupCalcDisabled;
return false;
}
mxGroup->meCalcState = sc::GroupCalcRunning;
if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aCode))
{
mxGroup->meCalcState = sc::GroupCalcDisabled;
return false;
}
mxGroup->meCalcState = sc::GroupCalcEnabled;
}
else
{
ScTokenArray aDummy;
if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aDummy))
{
mxGroup->meCalcState = sc::GroupCalcDisabled;
return false;
}
}
if (mxGroup->meCalcState == sc::GroupCalcRunning)
mxGroup->meCalcState = sc::GroupCalcEnabled;
return true;
}
......
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