ThreadWeaver

executewrapper.cpp
1 /* -*- C++ -*-
2  Class to manipulate job execution in ThreadWeaver.
3 
4  SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "executewrapper_p.h"
10 
11 namespace ThreadWeaver
12 {
13 ExecuteWrapper::ExecuteWrapper()
14 {
15 }
16 
17 Executor *ExecuteWrapper::wrap(Executor *previous)
18 {
19  return wrapped.fetchAndStoreOrdered(previous);
20 }
21 
22 Executor *ExecuteWrapper::unwrap(const JobPointer &job)
23 {
24  Executor *executor = job->setExecutor(wrapped.fetchAndStoreOrdered(nullptr));
25  Q_ASSERT_X(executor == this, Q_FUNC_INFO, "ExecuteWrapper can only unwrap itself!");
26  return executor;
27 }
28 
29 void ExecuteWrapper::begin(const JobPointer &job, Thread *thread)
30 {
31  Q_ASSERT(wrapped.loadAcquire() != nullptr);
32  wrapped.loadAcquire()->begin(job, thread);
33 }
34 
35 void ExecuteWrapper::execute(const JobPointer &job, Thread *thread)
36 {
37  executeWrapped(job, thread);
38 }
39 
40 void ExecuteWrapper::executeWrapped(const JobPointer &job, Thread *thread)
41 {
42  Executor *executor = wrapped.loadAcquire();
43  Q_ASSERT_X(executor != nullptr, Q_FUNC_INFO, "Wrapped Executor cannot be zero!");
44  executor->execute(job, thread);
45 }
46 
47 void ExecuteWrapper::end(const JobPointer &job, Thread *thread)
48 {
49  Q_ASSERT(wrapped.loadAcquire() != nullptr);
50  wrapped.loadAcquire()->end(job, thread);
51 }
52 
53 }
54 
55 #include "executewrapper_p.h"
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:10:21 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.