LibreOffice LibreOffice 26.2 SDK C/C++ API Reference

Loading...
Searching...
No Matches
thread.h
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
20/*
21 * This file is part of LibreOffice published API.
22 */
23
24#ifndef INCLUDED_OSL_THREAD_H
25#define INCLUDED_OSL_THREAD_H
26
27#include "sal/config.h"
28
29#include "osl/time.h"
30#include "rtl/textenc.h"
31#include "sal/saldllapi.h"
32
33#ifdef __cplusplus
34 extern "C" {
35#endif
36
41 typedef void* oslThread;
42
45 typedef void (SAL_CALL *oslWorkerFunction)(void*);
46
52 typedef enum
53{
54 osl_Thread_PriorityHighest,
55 osl_Thread_PriorityAboveNormal,
56 osl_Thread_PriorityNormal,
57 osl_Thread_PriorityBelowNormal,
58 osl_Thread_PriorityLowest,
59 osl_Thread_PriorityUnknown, /* don't use to set */
60 osl_Thread_Priority_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
61} oslThreadPriority;
62
63
64 typedef sal_uInt32 oslThreadIdentifier;
65
66 typedef void* oslThreadKey;
67
79 SAL_DLLPUBLIC oslThread SAL_CALL osl_createThread(oslWorkerFunction pWorker, void* pThreadData);
80
92 SAL_DLLPUBLIC oslThread SAL_CALL osl_createSuspendedThread(oslWorkerFunction pWorker, void* pThreadData);
93
101 SAL_DLLPUBLIC oslThreadIdentifier SAL_CALL osl_getThreadIdentifier(oslThread Thread);
102
110 SAL_DLLPUBLIC void SAL_CALL osl_destroyThread(oslThread Thread);
111
117 SAL_DLLPUBLIC void SAL_CALL osl_resumeThread(oslThread Thread);
118
124 SAL_DLLPUBLIC void SAL_CALL osl_suspendThread(oslThread Thread);
125
132 SAL_DLLPUBLIC void SAL_CALL osl_setThreadPriority(oslThread Thread, oslThreadPriority Priority);
133
140 SAL_DLLPUBLIC oslThreadPriority SAL_CALL osl_getThreadPriority(const oslThread Thread);
141
148 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread);
149
155 SAL_DLLPUBLIC void SAL_CALL osl_joinWithThread(oslThread Thread);
156
162 SAL_DLLPUBLIC void SAL_CALL osl_waitThread(const TimeValue* pDelay);
163
169 SAL_DLLPUBLIC void SAL_CALL osl_terminateThread(oslThread Thread);
170
179 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread);
180
188 SAL_DLLPUBLIC void SAL_CALL osl_yieldThread(void);
189
200 SAL_DLLPUBLIC void SAL_CALL osl_setThreadName(char const * name);
201
202/* Callback when data stored in a thread key is no longer needed */
203
204 typedef void (SAL_CALL *oslThreadKeyCallbackFunction)(void *);
205
207 SAL_DLLPUBLIC oslThreadKey SAL_CALL osl_createThreadKey(oslThreadKeyCallbackFunction pCallback);
208
210 SAL_DLLPUBLIC void SAL_CALL osl_destroyThreadKey(oslThreadKey Key);
211
213 SAL_DLLPUBLIC void* SAL_CALL osl_getThreadKeyData(oslThreadKey Key);
214
216 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_setThreadKeyData(oslThreadKey Key, void *pData);
217
219 SAL_DLLPUBLIC rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding(void);
220
224 SAL_DLLPUBLIC rtl_TextEncoding SAL_CALL osl_setThreadTextEncoding(rtl_TextEncoding Encoding);
225
226#ifdef __cplusplus
227}
228#endif
229
230#endif // INCLUDED_OSL_THREAD_H
231
232/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_MAX_ENUM
#define SAL_MAX_ENUM
Definition types.h:205
sal_Bool
unsigned char sal_Bool
Definition types.h:38
config.h
saldllapi.h
SAL_DLLPUBLIC
#define SAL_DLLPUBLIC
Definition saldllapi.h:34
textenc.h
rtl_TextEncoding
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition textenc.h:37
time.h
osl_terminateThread
SAL_DLLPUBLIC void osl_terminateThread(oslThread Thread)
The requested thread will get terminate the next time scheduleThread() is called.
osl_setThreadPriority
SAL_DLLPUBLIC void osl_setThreadPriority(oslThread Thread, oslThreadPriority Priority)
Changes the threads priority.
oslWorkerFunction
void(* oslWorkerFunction)(void *)
the function-ptr.
Definition thread.h:45
osl_resumeThread
SAL_DLLPUBLIC void osl_resumeThread(oslThread Thread)
Wake-up a thread that was suspended with suspend() or createSuspended().
osl_createThread
SAL_DLLPUBLIC oslThread osl_createThread(oslWorkerFunction pWorker, void *pThreadData)
Create the thread, using the function-ptr pWorker as its main (worker) function.
osl_createSuspendedThread
SAL_DLLPUBLIC oslThread osl_createSuspendedThread(oslWorkerFunction pWorker, void *pThreadData)
Create the thread, using the function-ptr pWorker as its main (worker) function.
oslThreadKey
void * oslThreadKey
Definition thread.h:66
osl_scheduleThread
SAL_DLLPUBLIC sal_Bool osl_scheduleThread(oslThread Thread)
Schedules in thread to wait till after time slice of specified thread.
osl_setThreadName
SAL_DLLPUBLIC void osl_setThreadName(char const *name)
Attempts to set the name of the current thread.
osl_setThreadTextEncoding
SAL_DLLPUBLIC rtl_TextEncoding osl_setThreadTextEncoding(rtl_TextEncoding Encoding)
Set the thread local text encoding.
osl_yieldThread
SAL_DLLPUBLIC void osl_yieldThread(void)
Offers the rest of the threads time-slice to the OS.
osl_destroyThread
SAL_DLLPUBLIC void osl_destroyThread(oslThread Thread)
Release the thread handle.
oslThreadKeyCallbackFunction
void(* oslThreadKeyCallbackFunction)(void *)
Definition thread.h:204
osl_getThreadIdentifier
SAL_DLLPUBLIC oslThreadIdentifier osl_getThreadIdentifier(oslThread Thread)
Get the identifier for the specified thread or if parameter Thread is NULL of the current active thre...
oslThreadPriority
oslThreadPriority
levels of thread-priority Note that oslThreadPriorityUnknown might be returned by getPriorityOfThread...
Definition thread.h:53
osl_Thread_Priority_FORCE_EQUAL_SIZE
@ osl_Thread_Priority_FORCE_EQUAL_SIZE
Definition thread.h:60
osl_Thread_PriorityUnknown
@ osl_Thread_PriorityUnknown
Definition thread.h:59
osl_Thread_PriorityHighest
@ osl_Thread_PriorityHighest
Definition thread.h:54
osl_Thread_PriorityBelowNormal
@ osl_Thread_PriorityBelowNormal
Definition thread.h:57
osl_Thread_PriorityNormal
@ osl_Thread_PriorityNormal
Definition thread.h:56
osl_Thread_PriorityAboveNormal
@ osl_Thread_PriorityAboveNormal
Definition thread.h:55
osl_Thread_PriorityLowest
@ osl_Thread_PriorityLowest
Definition thread.h:58
osl_joinWithThread
SAL_DLLPUBLIC void osl_joinWithThread(oslThread Thread)
Blocks the calling thread until Thread has terminated.
osl_getThreadTextEncoding
SAL_DLLPUBLIC rtl_TextEncoding osl_getThreadTextEncoding(void)
Get the current thread local text encoding.
osl_destroyThreadKey
SAL_DLLPUBLIC void osl_destroyThreadKey(oslThreadKey Key)
Destroy a key to an associated thread local storage pointer.
osl_getThreadKeyData
SAL_DLLPUBLIC void * osl_getThreadKeyData(oslThreadKey Key)
Get to key associated thread specific data.
oslThreadIdentifier
sal_uInt32 oslThreadIdentifier
Definition thread.h:64
osl_setThreadKeyData
SAL_DLLPUBLIC sal_Bool osl_setThreadKeyData(oslThreadKey Key, void *pData)
Set to key associated thread specific data.
oslThread
void * oslThread
Opaque data type for threads.
Definition thread.h:41
osl_isThreadRunning
SAL_DLLPUBLIC sal_Bool osl_isThreadRunning(const oslThread Thread)
Returns True if the thread was created and has not terminated yet.
osl_suspendThread
SAL_DLLPUBLIC void osl_suspendThread(oslThread Thread)
Suspend the execution of the thread.
osl_getThreadPriority
SAL_DLLPUBLIC oslThreadPriority osl_getThreadPriority(const oslThread Thread)
Retrieves the threads priority.
osl_createThreadKey
SAL_DLLPUBLIC oslThreadKey osl_createThreadKey(oslThreadKeyCallbackFunction pCallback)
Create a key to an associated thread local storage pointer.
osl_waitThread
SAL_DLLPUBLIC void osl_waitThread(const TimeValue *pDelay)
Suspends the execution of the calling thread for at least the given time.
TimeValue
Time since Jan-01-1970.
Definition time.h:76