LibreOffice LibreOffice 25.8 SDK C/C++ API Reference

thread.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
10/*
11 * This file is part of LibreOffice published API.
12 */
13
14#ifndef INCLUDED_SALHELPER_THREAD_HXX
15#define INCLUDED_SALHELPER_THREAD_HXX
16
17#include "sal/config.h"
18
19#include <cstddef>
20
21#include "osl/thread.hxx"
22#include "sal/types.h"
23#include "salhelper/salhelperdllapi.h"
24#include "salhelper/simplereferenceobject.hxx"
25
26 namespace salhelper
27{
33 class SALHELPER_DLLPUBLIC Thread : public salhelper::SimpleReferenceObject, private osl::Thread
34{
35 public:
40 Thread(char const* name);
41
52 void launch();
53
54 using osl::Thread::getIdentifier;
55 using osl::Thread::join;
56 using osl::Thread::schedule;
57 using osl::Thread::terminate;
58
59 // While the below static member functions should arguably always be called
60 // with qualified (osl::Thread) names, compilers would still complain that
61 // they are inaccessible from within derivations of salhelper::Thread (an
62 // alternative would be to force such derivations to use global names,
63 // prefixed with ::osl::Thread):
64 using osl::Thread::getCurrentIdentifier;
65 using osl::Thread::wait;
66 using osl::Thread::yield;
67
68 static void* operator new(std::size_t size)
69 {
70 return SimpleReferenceObject::operator new(size);
71 }
72
73 static void operator delete(void* pointer) { SimpleReferenceObject::operator delete(pointer); }
74
75 protected:
76 virtual ~Thread() SAL_OVERRIDE;
77
83 virtual void execute() = 0;
84
85private:
86 virtual void SAL_CALL run() SAL_OVERRIDE;
87
88 virtual void SAL_CALL onTerminated() SAL_OVERRIDE;
89
90 char const* name_;
91};
92}
93
94#endif
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
config.h
types.h
SAL_OVERRIDE
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:409
simplereferenceobject.hxx
salhelperdllapi.h
SALHELPER_DLLPUBLIC
#define SALHELPER_DLLPUBLIC
Definition: salhelperdllapi.h:32
salhelper
Definition: condition.hxx:34
salhelper::SimpleReferenceObject
A simple base implementation for reference-counted objects.
Definition: simplereferenceobject.hxx:62
salhelper::Thread
A safe encapsulation of osl::Thread.
Definition: thread.hxx:34
salhelper::Thread::Thread
Thread(char const *name)
salhelper::Thread::~Thread
virtual ~Thread() SAL_OVERRIDE
salhelper::Thread::launch
void launch()
Launch the thread.
osl::Thread
A thread abstraction.
Definition: thread.hxx:53
osl::Thread::getIdentifier
oslThreadIdentifier getIdentifier() const
Definition: thread.hxx:135
osl::Thread::getCurrentIdentifier
static oslThreadIdentifier getCurrentIdentifier()
Definition: thread.hxx:140
osl::Thread::yield
static void yield()
Definition: thread.hxx:150
osl::Thread::schedule
virtual bool schedule()
Definition: thread.hxx:159
osl::Thread::join
virtual void join()
Definition: thread.hxx:114
osl::Thread::wait
static void wait(const TimeValue &Delay)
Definition: thread.hxx:145
osl::Thread::terminate
virtual void terminate()
Definition: thread.hxx:108
thread.hxx