fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / tool / clkernelthread.cxx
blob6c5afc0e55ed45c5c7f0303c636574c8c56499e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/log.hxx>
12 #include "formulagroup.hxx"
13 #include "grouptokenconverter.hxx"
15 #include "clkernelthread.hxx"
17 using namespace std;
19 namespace sc {
21 CLBuildKernelThread::CLBuildKernelThread() :
22 salhelper::Thread("opencl-build-kernel-thread")
26 CLBuildKernelThread::~CLBuildKernelThread()
30 void CLBuildKernelThread::execute()
32 SAL_INFO("sc.opencl.thread", "running");
34 bool done = false;
35 while (!done)
37 SAL_INFO("sc.opencl.thread", "waiting for condition");
38 maQueueCondition.wait();
39 SAL_INFO("sc.opencl.thread", "got condition");
40 osl::ResettableMutexGuard aGuard(maQueueMutex);
41 maQueueCondition.reset();
42 while (!maQueue.empty())
44 CLBuildKernelWorkItem aWorkItem = maQueue.front();
45 maQueue.pop();
46 aGuard.clear();
48 switch (aWorkItem.meWhatToDo)
50 case CLBuildKernelWorkItem::COMPILE:
51 SAL_INFO("sc.opencl.thread", "told to compile group " << aWorkItem.mxGroup << " (state " << aWorkItem.mxGroup->meCalcState << ") to binary");
52 aWorkItem.mxGroup->compileOpenCLKernel();
53 SAL_INFO("sc.opencl.thread", "group " << aWorkItem.mxGroup << " compilation done");
54 maCompilationDoneCondition.set();
55 break;
56 case CLBuildKernelWorkItem::FINISH:
57 SAL_INFO("sc.opencl.thread", "told to finish");
58 done = true;
59 break;
62 aGuard.reset();
67 void CLBuildKernelThread::push(CLBuildKernelWorkItem item)
69 osl::MutexGuard guard(maQueueMutex);
70 maQueue.push(item);
71 maQueueCondition.set();
73 // This is only to ensure that the OpenCL parameters are initialized on
74 // the main thread before spawning a worker thread for kernel
75 // pre-compilation.
76 sc::FormulaGroupInterpreter::getStatic();
79 void CLBuildKernelThread::produce()
83 void CLBuildKernelThread::consume()
87 void CLBuildKernelThread::finish()
89 SAL_INFO("sc.opencl", "telling thread to finish");
90 CLBuildKernelWorkItem aWorkItem;
91 aWorkItem.meWhatToDo = CLBuildKernelWorkItem::FINISH;
92 push(aWorkItem);
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */