ObjFW  Diff

Differences From Artifact [36e8a35200]:

To Artifact [894be3846a]:


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
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#ifndef _WIN32
#include <pthread.h>
#else
#include <windows.h>
#endif

#import "OFObject.h"

/**
 * A Thread Local Storage key.
 */
@interface OFTLSKey: OFObject
{
@public
#ifndef _WIN32
	pthread_key_t key;
#else
	DWORD key;
#endif
}

/**
 * \param destructor A destructor that is called when the thread is terminated
 * \return A new autoreleased Thread Local Storage key
 */
+ tlsKeyWithDestructor: (void(*)(void*))destructor;

/**
 * \param destructor A destructor that is called when the thread is terminated
 * \return An initialized Thread Local Storage key
 */
- initWithDestructor: (void(*)(void*))destructor;
@end

/**
 * The OFThread class provides portable threads.
 *
 * To use it, you should create a new class derived from it and reimplement
 * main.
 */
@interface OFThread: OFObject
{
	id object;
#ifndef _WIN32
	pthread_t thread;
#else
	HANDLE thread;

@public
	id retval;
#endif
}

/**
 * \param obj An object that is passed to the main method as a copy or nil
 * \return A new autoreleased thread
 */
+ threadWithObject: (id)obj;











|
<
<
<
<

|







<
|
<
<
<






|





|











<
|
<
<



<







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
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"





#import "threading.h"

/**
 * A Thread Local Storage key.
 */
@interface OFTLSKey: OFObject
{
@public

	of_tlskey_t key;



}

/**
 * \param destructor A destructor that is called when the thread is terminated
 * \return A new autoreleased Thread Local Storage key
 */
+ tlsKeyWithDestructor: (void(*)(id))destructor;

/**
 * \param destructor A destructor that is called when the thread is terminated
 * \return An initialized Thread Local Storage key
 */
- initWithDestructor: (void(*)(id))destructor;
@end

/**
 * The OFThread class provides portable threads.
 *
 * To use it, you should create a new class derived from it and reimplement
 * main.
 */
@interface OFThread: OFObject
{
	id object;

	of_thread_t thread;



@public
	id retval;

}

/**
 * \param obj An object that is passed to the main method as a copy or nil
 * \return A new autoreleased thread
 */
+ threadWithObject: (id)obj;
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
@end

/**
 * A class for creating mutual exclusions.
 */
@interface OFMutex: OFObject
{
#ifndef _WIN32
	pthread_mutex_t mutex;
#else
	CRITICAL_SECTION mutex;
#endif
}

/**
 * \return A new autoreleased mutex.
 */
+ mutex;








<
|
<
<
<







101
102
103
104
105
106
107

108



109
110
111
112
113
114
115
@end

/**
 * A class for creating mutual exclusions.
 */
@interface OFMutex: OFObject
{

	of_mutex_t mutex;



}

/**
 * \return A new autoreleased mutex.
 */
+ mutex;