LibreOffice Module sw (master)  1
observablethread.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_OBSERVABLETHREAD_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_OBSERVABLETHREAD_HXX
21 
22 #include <osl/thread.hxx>
23 #include <osl/interlck.h>
25 #include <memory>
26 
28 
39 class ObservableThread : public osl::Thread,
41 {
42  public:
43 
44  virtual ~ObservableThread() override;
45 
46  void SetListener( std::weak_ptr< IFinishedThreadListener > const & pThreadListener,
47  const oslInterlockedCount nThreadID );
48 
49  // resolve ambiguity
50  using SimpleReferenceObject::operator new;
51  using SimpleReferenceObject::operator delete;
52 
53  protected:
54 
56 
64  virtual void SAL_CALL run() override;
65 
66  virtual void threadFunction() = 0;
67 
76  virtual void SAL_CALL onTerminated() override;
77 
78  private:
79 
80  oslInterlockedCount mnThreadID;
81 
82  std::weak_ptr< IFinishedThreadListener > mpThreadListener;
83 
84 };
85 #endif
86 
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~ObservableThread() override
virtual void SAL_CALL run() override
intrinsic function of the thread
class for an observable thread
std::weak_ptr< IFinishedThreadListener > mpThreadListener
void SetListener(std::weak_ptr< IFinishedThreadListener > const &pThreadListener, const oslInterlockedCount nThreadID)
oslInterlockedCount mnThreadID
interface class to listen on the finish of a thread
virtual void SAL_CALL onTerminated() override
method called, when thread has finished its work
virtual void threadFunction()=0