ObjFW  Check-in [386962cb17]

Overview
Comment:threading_winapi.m: Cosmetic change
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 386962cb17b6d2d154ab0cf5956b4d9fb290c94784a2d9e19cd226a10f57e5f2
User & Date: js on 2016-03-28 20:14:59
Other Links: manifest | tags
Context
2016-03-28
23:43
Style consistency changes check-in: 543eb96c02 user: js tags: trunk
20:14
threading_winapi.m: Cosmetic change check-in: 386962cb17 user: js tags: trunk
19:50
socket.m: Remove leftover from port registry check-in: 9394805757 user: js tags: trunk
Changes

Modified src/threading_winapi.m from [89698eef26] to [8257bd1f48].

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
	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 < -1 || attr->priority > 1)
			return false;

		if (attr->priority < 0)
			priority = THREAD_PRIORITY_LOWEST +
			    (1.0 + attr->priority) *
			    (THREAD_PRIORITY_NORMAL - THREAD_PRIORITY_LOWEST);
		else
			priority = THREAD_PRIORITY_NORMAL +
			    attr->priority *
			    (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_NORMAL);

		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
		return true;
}

bool
of_thread_join(of_thread_t thread)
{
	if (WaitForSingleObject(thread, INFINITE))
		return false;







|
>
|
>
>

|
>
>












<
<
|
<
<
<
<
|
|
|
<
<
|







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
	return true;
}

bool
of_thread_new(of_thread_t *thread, void (*function)(id), id object,
    const of_thread_attr_t *attr)
{
	*thread = CreateThread(NULL, (attr != NULL ? attr->stackSize : 0),
	    (LPTHREAD_START_ROUTINE)function, (__bridge void*)object, 0, NULL);

	if (thread == NULL)
		return false;

	if (attr != NULL && attr->priority != 0) {
		DWORD priority;

		if (attr->priority < -1 || attr->priority > 1)
			return false;

		if (attr->priority < 0)
			priority = THREAD_PRIORITY_LOWEST +
			    (1.0 + attr->priority) *
			    (THREAD_PRIORITY_NORMAL - THREAD_PRIORITY_LOWEST);
		else
			priority = THREAD_PRIORITY_NORMAL +
			    attr->priority *
			    (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_NORMAL);



		if (!SetThreadPriority(*thread, priority))




			return false;
	}



	return true;
}

bool
of_thread_join(of_thread_t thread)
{
	if (WaitForSingleObject(thread, INFINITE))
		return false;