Overview
| Comment: | Check thread attributes before spawning the thread |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
164475afdb491088789cbe767594111b |
| User & Date: | js on 2020-06-14 16:07:41 |
| Other Links: | manifest | tags |
Context
|
2020-06-14
| ||
| 19:00 | .travis.yml: Remove STDOUT_SIMPLE (check-in: 141b8181c0 user: js tags: trunk) | |
| 16:07 | Check thread attributes before spawning the thread (check-in: 164475afdb user: js tags: trunk) | |
| 15:50 | Add a function wrapper for threads on Windows (check-in: e342aa8358 user: js tags: trunk) | |
Changes
Modified src/platform/windows/thread.m from [ec067e732d] to [d3d9eb9ec8].
| ︙ | ︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
return true;
}
bool
of_thread_new(of_thread_t *thread, const char *name, void (*function)(id),
id object, const of_thread_attr_t *attr)
{
struct thread_context *context;
DWORD threadID;
if ((context = malloc(sizeof(*context))) == NULL) {
errno = ENOMEM;
return false;
}
context->function = function;
| > > > > > > > > > > > > > > > > > | 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 |
return true;
}
bool
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) {
errno = EINVAL;
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 ((context = malloc(sizeof(*context))) == NULL) {
errno = ENOMEM;
return false;
}
context->function = function;
|
| ︙ | ︙ | |||
79 80 81 82 83 84 85 | } free(context); errno = errNo; return false; } | | < < < < < < < < < < < < < < < < < | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
}
free(context);
errno = errNo;
return false;
}
if (attr != NULL && attr->priority != 0)
OF_ENSURE(!SetThreadPriority(*thread, priority));
return true;
}
bool
of_thread_join(of_thread_t thread)
{
|
| ︙ | ︙ |