LibreOffice
LibreOffice 6.0 SDK C/C++ API Reference
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 #ifndef INCLUDED_OSL_THREAD_H
21 #define INCLUDED_OSL_THREAD_H
22 
23 #include <sal/config.h>
24 
25 #include <osl/time.h>
26 #include <rtl/textenc.h>
27 #include <sal/saldllapi.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
37 typedef void* oslThread;
38 
41 typedef void (SAL_CALL *oslWorkerFunction)(void*);
42 
48 typedef enum
49 {
55  osl_Thread_PriorityUnknown, /* don't use to set */
58 
59 
60 typedef sal_uInt32 oslThreadIdentifier;
61 
62 typedef void* oslThreadKey;
63 
75 SAL_DLLPUBLIC oslThread SAL_CALL osl_createThread(oslWorkerFunction pWorker, void* pThreadData);
76 
88 SAL_DLLPUBLIC oslThread SAL_CALL osl_createSuspendedThread(oslWorkerFunction pWorker, void* pThreadData);
89 
97 SAL_DLLPUBLIC oslThreadIdentifier SAL_CALL osl_getThreadIdentifier(oslThread Thread);
98 
106 SAL_DLLPUBLIC void SAL_CALL osl_destroyThread(oslThread Thread);
107 
113 SAL_DLLPUBLIC void SAL_CALL osl_resumeThread(oslThread Thread);
114 
120 SAL_DLLPUBLIC void SAL_CALL osl_suspendThread(oslThread Thread);
121 
128 SAL_DLLPUBLIC void SAL_CALL osl_setThreadPriority(oslThread Thread, oslThreadPriority Priority);
129 
136 SAL_DLLPUBLIC oslThreadPriority SAL_CALL osl_getThreadPriority(const oslThread Thread);
137 
144 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread);
145 
151 SAL_DLLPUBLIC void SAL_CALL osl_joinWithThread(oslThread Thread);
152 
158 SAL_DLLPUBLIC void SAL_CALL osl_waitThread(const TimeValue* pDelay);
159 
165 SAL_DLLPUBLIC void SAL_CALL osl_terminateThread(oslThread Thread);
166 
175 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread);
176 
184 SAL_DLLPUBLIC void SAL_CALL osl_yieldThread(void);
185 
198 SAL_DLLPUBLIC void SAL_CALL osl_setThreadName(char const * name);
199 
200 /* Callback when data stored in a thread key is no longer needed */
201 
202 typedef void (SAL_CALL *oslThreadKeyCallbackFunction)(void *);
203 
205 SAL_DLLPUBLIC oslThreadKey SAL_CALL osl_createThreadKey(oslThreadKeyCallbackFunction pCallback);
206 
208 SAL_DLLPUBLIC void SAL_CALL osl_destroyThreadKey(oslThreadKey Key);
209 
211 SAL_DLLPUBLIC void* SAL_CALL osl_getThreadKeyData(oslThreadKey Key);
212 
214 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_setThreadKeyData(oslThreadKey Key, void *pData);
215 
218 
223 
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 #endif // INCLUDED_OSL_THREAD_H
229 
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC void osl_destroyThreadKey(oslThreadKey Key)
Destroy a key to an associated thread local storage pointer.
SAL_DLLPUBLIC void osl_setThreadPriority(oslThread Thread, oslThreadPriority Priority)
Changes the threads priority.
Definition: thread.h:54
#define SAL_DLLPUBLIC
Definition: saldllapi.h:30
Definition: thread.h:50
void(* oslWorkerFunction)(void *)
the function-ptr.
Definition: thread.h:41
SAL_DLLPUBLIC void osl_yieldThread(void)
Offers the rest of the threads time-slice to the OS.
SAL_DLLPUBLIC sal_Bool osl_setThreadKeyData(oslThreadKey Key, void *pData)
Set to key associated thread specific data.
SAL_DLLPUBLIC void osl_suspendThread(oslThread Thread)
Suspend the execution of the thread.
SAL_DLLPUBLIC void osl_setThreadName(char const *name)
Attempts to set the name of the current thread.
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...
void * oslThread
Opaque data type for threads.
Definition: thread.h:37
#define SAL_MAX_ENUM
Definition: types.h:228
SAL_DLLPUBLIC sal_Bool osl_scheduleThread(oslThread Thread)
Schedules in thread to wait till after time slice of specified thread.
sal_uInt32 oslThreadIdentifier
Definition: thread.h:60
unsigned char sal_Bool
Definition: types.h:39
SAL_DLLPUBLIC void osl_resumeThread(oslThread Thread)
Wake-up a thread that was suspended with suspend() or createSuspended().
SAL_DLLPUBLIC void osl_destroyThread(oslThread Thread)
Release the thread handle.
Definition: thread.h:53
SAL_DLLPUBLIC rtl_TextEncoding osl_setThreadTextEncoding(rtl_TextEncoding Encoding)
Set the thread local text encoding.
SAL_DLLPUBLIC oslThread osl_createThread(oslWorkerFunction pWorker, void *pThreadData)
Create the thread, using the function-ptr pWorker as its main (worker) function.
SAL_DLLPUBLIC rtl_TextEncoding osl_getThreadTextEncoding(void)
Get the current thread local text encoding.
SAL_DLLPUBLIC oslThreadKey osl_createThreadKey(oslThreadKeyCallbackFunction pCallback)
Create a key to an associated thread local storage pointer.
SAL_DLLPUBLIC oslThread osl_createSuspendedThread(oslWorkerFunction pWorker, void *pThreadData)
Create the thread, using the function-ptr pWorker as its main (worker) function.
void * oslThreadKey
Definition: thread.h:62
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:33
SAL_DLLPUBLIC void osl_terminateThread(oslThread Thread)
The requested thread will get terminate the next time scheduleThread() is called. ...
SAL_DLLPUBLIC sal_Bool osl_isThreadRunning(const oslThread Thread)
Returns True if the thread was created and has not terminated yet.
oslThreadPriority
levels of thread-priority Note that oslThreadPriorityUnknown might be returned by getPriorityOfThread...
Definition: thread.h:48
Definition: thread.h:55
SAL_DLLPUBLIC void osl_joinWithThread(oslThread Thread)
Blocks the calling thread until Thread has terminated.
SAL_DLLPUBLIC oslThreadPriority osl_getThreadPriority(const oslThread Thread)
Retrieves the threads priority.
Definition: time.h:66
SAL_DLLPUBLIC void osl_waitThread(const TimeValue *pDelay)
Suspends the execution of the calling thread for at least the given time.
Definition: thread.h:52
void(* oslThreadKeyCallbackFunction)(void *)
Definition: thread.h:202
Definition: thread.h:51
SAL_DLLPUBLIC void * osl_getThreadKeyData(oslThreadKey Key)
Get to key associated thread specific data.