ObjFW  Diff

Differences From Artifact [73d2b0526d]:

To Artifact [b5d0945c6a]:

  • File src/threading_winapi.m — part of check-in [52e02c06ca] at 2014-08-01 12:27:29 on branch trunk — Change return type for thread main

    This changes the return type to void, as the return type of a thread's
    main depends on the threading implementation used. For pthreads, it adds
    a wrapper function which returns NULL to avoid problems with bogus
    return values. For WinAPI threads, the function is just casted, as bogus
    return values don't seem to matter there. (user: js, size: 3783) [annotate] [blame] [check-ins using]


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
	    (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_LOWEST);
	attr->stackSize = 0;

	return true;
}

bool
of_thread_new(of_thread_t *thread, id (*function)(id), id data,
    const of_thread_attr_t *attr)
{
	size_t stackSize = 0;
	int priority = 0;

	if (attr != NULL) {
		if (attr->priority < 0 || attr->priority > 1)
			return false;

		priority = THREAD_PRIORITY_LOWEST + attr->priority *
		    (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_LOWEST);
		stackSize = attr->stackSize;
	}

	*thread = CreateThread(NULL, stackSize,
	    (LPTHREAD_START_ROUTINE)function, (__bridge void*)data, 0, NULL);

	if (thread == NULL)
		return false;

	if (priority > 0)
		return SetThreadPriority(*thread, priority);
	else







|















|







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
	    (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_LOWEST);
	attr->stackSize = 0;

	return true;
}

bool
of_thread_new(of_thread_t *thread, void (*function)(id), id object,
    const of_thread_attr_t *attr)
{
	size_t stackSize = 0;
	int priority = 0;

	if (attr != NULL) {
		if (attr->priority < 0 || attr->priority > 1)
			return false;

		priority = THREAD_PRIORITY_LOWEST + attr->priority *
		    (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_LOWEST);
		stackSize = attr->stackSize;
	}

	*thread = CreateThread(NULL, stackSize,
	    (LPTHREAD_START_ROUTINE)function, (__bridge void*)object, 0, NULL);

	if (thread == NULL)
		return false;

	if (priority > 0)
		return SetThreadPriority(*thread, priority);
	else