Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2262dd29550b418d9176665153a373dc188b817e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*******************************************************************************
 * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * CONTRIBUTORS:
 * 		Thomas Schuetz, Thomas Jung (initial contribution)
 *
 *******************************************************************************/

#ifndef _ETTHREAD_H_
#define _ETTHREAD_H_

/**
 * etThread.h defines a generic interface for platform specific implementations of a thread
 *
 * */


#include "etDatatypes.h"

/*
 * typedefs for etThread
 */

typedef int32 etStacksize;
typedef int32 etPriority;
typedef charPtr etThreadname;
typedef void (*etThreadFunction)(void *);

/**
 * etThread holds all data needed to handle a thread instance
 * the struct has to be filled before calling etThread_construct except for osData and osId
 **/
typedef struct etThread{
	etOSThreadData osData;		/**< OS specific thread data (e.g. handle or id) -> is filled in by etThread_construct **/
	etOSThreadId osId;			/**< integer thread id (used e.g. for debugging)  -> is filled in by etThread_construct **/
	etStacksize stacksize;		/**< configuration of stacksize -> has to be filled in by caller of etThread_construct **/
	etPriority priority;		/**< configuration of priority -> has to be filled in by caller of etThread_construct **/
	etThreadname threadName;	/**< configuration of threadName -> has to be filled in by caller of etThread_construct **/
	etThreadFunction threadFunction; /**< call back function to be called by thread -> has to be filled in by caller of etThread_construct **/
	void* threadFunctionData;	/**< data for call back function to be called by thread -> has to be filled in by caller of etThread_construct **/
} etThread;

// TODO: add return values for error handling

/**
 * create and start a new thread
 * \param self pointer to thread instance
 */
void etThread_construct(etThread* self); /*TODO: add all neededarguments to constructor arguments */

/**
 * stop and destroy a new thread
 * \param self pointer to thread instance
 */
void etThread_destruct(etThread* self);

/**
 * pausing the execution of the thread for <b>millis</b> milliseconds
 * \param millis sleeping time in milliseconds
 */
void etThread_sleep(etInt32 millis);

/**
 * get the self pointer of the OS specific data (e.g. handle) of the current thread
 * \return self pointer of the OS specific data (e.g. handle) of the current thread
 */
etOSThreadData etThread_self(void);

/**
 * get the unique id of the current thread
 * \return unique id of the current thread
 */
etOSThreadId etThread_self_id(void);


#endif /* _ETTHREAD_H_ */

Back to the top