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
|
{
context->function(context->object);
free(context);
}
int
of_thread_attr_init(of_thread_attr_t *attr)
{
attr->priority = 0;
attr->stackSize = 0;
return 0;
}
int
of_thread_new(of_thread_t *thread, const char *name, void (*function)(id),
id object, const of_thread_attr_t *attr)
{
DWORD priority = THREAD_PRIORITY_NORMAL;
struct thread_context *context;
DWORD threadID;
if (attr != NULL && attr->priority != 0) {
if (attr->priority < -1 || attr->priority > 1)
|
|
|
|
|
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
|
{
context->function(context->object);
free(context);
}
int
OFPlainThreadAttributesInit(OFPlainThreadAttributes *attr)
{
attr->priority = 0;
attr->stackSize = 0;
return 0;
}
int
OFPlainThreadNew(OFPlainThread *thread, const char *name, void (*function)(id),
id object, const OFPlainThreadAttributes *attr)
{
DWORD priority = THREAD_PRIORITY_NORMAL;
struct thread_context *context;
DWORD threadID;
if (attr != NULL && attr->priority != 0) {
if (attr->priority < -1 || attr->priority > 1)
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
if (attr != NULL && attr->priority != 0)
OF_ENSURE(!SetThreadPriority(*thread, priority));
return 0;
}
int
of_thread_join(of_thread_t thread)
{
switch (WaitForSingleObject(thread, INFINITE)) {
case WAIT_OBJECT_0:
CloseHandle(thread);
return 0;
case WAIT_FAILED:
switch (GetLastError()) {
case ERROR_INVALID_HANDLE:
return EINVAL;
default:
OF_ENSURE(0);
}
default:
OF_ENSURE(0);
}
}
int
of_thread_detach(of_thread_t thread)
{
CloseHandle(thread);
return 0;
}
void
of_thread_set_name(const char *name)
{
}
|
|
|
|
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
if (attr != NULL && attr->priority != 0)
OF_ENSURE(!SetThreadPriority(*thread, priority));
return 0;
}
int
OFPlainThreadJoin(OFPlainThread thread)
{
switch (WaitForSingleObject(thread, INFINITE)) {
case WAIT_OBJECT_0:
CloseHandle(thread);
return 0;
case WAIT_FAILED:
switch (GetLastError()) {
case ERROR_INVALID_HANDLE:
return EINVAL;
default:
OF_ENSURE(0);
}
default:
OF_ENSURE(0);
}
}
int
OFPlainThreadDetach(OFPlainThread thread)
{
CloseHandle(thread);
return 0;
}
void
OFSetThreadName(const char *name)
{
}
|