OCILIB (C and C++ Driver for Oracle)  4.7.6
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Thread.hpp
1 /*
2  * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI)
3  *
4  * Website: http://www.ocilib.net
5  *
6  * Copyright (c) 2007-2023 Vincent ROGIER <vince.rogier@ocilib.net>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #pragma once
22 
23 #include "ocilibcpp/types.hpp"
24 
25 namespace ocilib
26 {
27 
29 {
30  return core::Check(OCI_ThreadCreate());
31 }
32 
33 inline void Thread::Destroy(ThreadHandle handle)
34 {
35  core::Check(OCI_ThreadFree(handle));
36 }
37 
38 inline void Thread::Run(ThreadHandle handle, ThreadProc func, AnyPointer arg)
39 {
40  core::Check(OCI_ThreadRun(handle, func, arg));
41 }
42 
43 inline void Thread::Join(ThreadHandle handle)
44 {
45  core::Check(OCI_ThreadJoin(handle));
46 }
47 
49 {
50  return core::Check(OCI_HandleGetThreadID(handle));
51 }
52 
53 }
POCI_THREAD ThreadProc
Thread callback.
Definition: types.hpp:1180
static ThreadHandle Create()
Create a Thread.
Definition: Thread.hpp:28
static void Join(ThreadHandle handle)
Join the given thread.
Definition: Thread.hpp:43
static void Destroy(ThreadHandle handle)
Destroy a thread.
Definition: Thread.hpp:33
static void Run(ThreadHandle handle, ThreadProc func, AnyPointer arg)
Execute the given routine within the given thread.
Definition: Thread.hpp:38
static ThreadId GetThreadId(ThreadHandle handle)
Return the system Thread ID of the given thread handle.
Definition: Thread.hpp:48
OCI_SYM_PUBLIC const void *OCI_API OCI_HandleGetThreadID(OCI_Thread *thread)
Return OCI Thread ID (OCIThreadId *) of an OCILIB OCI_Thread object.
OCI_SYM_PUBLIC boolean OCI_API OCI_ThreadRun(OCI_Thread *thread, POCI_THREAD proc, void *arg)
Execute the given routine within the given thread object.
OCI_SYM_PUBLIC OCI_Thread *OCI_API OCI_ThreadCreate(void)
Create a Thread object.
OCI_SYM_PUBLIC boolean OCI_API OCI_ThreadJoin(OCI_Thread *thread)
Join the given thread.
OCI_SYM_PUBLIC boolean OCI_API OCI_ThreadFree(OCI_Thread *thread)
Destroy a thread object.
static T Check(T result)
Internal usage. Checks if the last OCILIB function call has raised an error. If so,...
Definition: Utils.hpp:53
OCILIB ++ Namespace.
const void * ThreadId
Thread Unique ID.
Definition: config.hpp:165
void * AnyPointer
Alias for the generic void pointer.
Definition: config.hpp:129
OCI_Thread * ThreadHandle
Alias for an OCI_Thread pointer.
Definition: config.hpp:156