Overview
Comment: | Change return type for thread main
This changes the return type to void, as the return type of a thread's |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
52e02c06ca4c99e0a49aea0aea056122 |
User & Date: | js on 2014-08-01 12:27:29 |
Other Links: | manifest | tags |
Context
2014-08-01
| ||
21:01 | Update buildsys check-in: beef05d289 user: js tags: trunk | |
12:27 | Change return type for thread main check-in: 52e02c06ca user: js tags: trunk | |
2014-07-24
| ||
18:02 | Warn if configure.ac is newer than configure check-in: 0ab38200a3 user: js tags: trunk | |
Changes
Modified src/OFThread.m from [b9ff0cb8da] to [e9af0aca95].
︙ | ︙ | |||
76 77 78 79 80 81 82 | #ifdef OF_HAVE_THREADS # import "threading.h" static of_tlskey_t threadSelfKey; static OFThread *mainThread; | | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | #ifdef OF_HAVE_THREADS # import "threading.h" static of_tlskey_t threadSelfKey; static OFThread *mainThread; static void callMain(id object) { OFThread *thread = (OFThread*)object; if (!of_tlskey_set(threadSelfKey, thread)) @throw [OFInitializationFailedException exceptionWithClass: [thread class]]; |
︙ | ︙ | |||
106 107 108 109 110 111 112 | thread->_running = OF_THREAD_WAITING_FOR_JOIN; objc_autoreleasePoolPop(thread->_pool); [OFAutoreleasePool OF_handleThreadTermination]; [thread release]; | < < | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | thread->_running = OF_THREAD_WAITING_FOR_JOIN; objc_autoreleasePoolPop(thread->_pool); [OFAutoreleasePool OF_handleThreadTermination]; [thread release]; } #endif @implementation OFThread #ifdef OF_HAVE_THREADS # if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) @synthesize threadBlock = _threadBlock; |
︙ | ︙ |
Modified src/threading.h from [0444440a9d] to [7cf05d0077].
︙ | ︙ | |||
93 94 95 96 97 98 99 | # define of_thread_current GetCurrentThread #else # error of_thread_is_current not implemented! # error of_thread_current not implemented! #endif extern bool of_thread_attr_init(of_thread_attr_t *attr); | | | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | # define of_thread_current GetCurrentThread #else # error of_thread_is_current not implemented! # error of_thread_current not implemented! #endif extern bool of_thread_attr_init(of_thread_attr_t *attr); extern bool of_thread_new(of_thread_t *thread, void (*function)(id), id object, const of_thread_attr_t *attr); extern void of_thread_set_name(of_thread_t thread, const char *name); extern bool of_thread_join(of_thread_t thread); extern bool of_thread_detach(of_thread_t thread); extern void OF_NO_RETURN of_thread_exit(void); extern void of_once(of_once_t *control, void (*func)(void)); extern bool of_mutex_new(of_mutex_t *mutex); |
︙ | ︙ |
Modified src/threading_pthread.m from [7ca1a9fd57] to [967081c426].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ bool of_thread_attr_init(of_thread_attr_t *attr) { pthread_attr_t pattr; if (pthread_attr_init(&pattr) != 0) | > > > > > > > > > > > > > > > > > > | 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 | * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ struct thread_ctx { void (*function)(id object); id object; }; static void* function_wrapper(void *data) { struct thread_ctx *ctx = data; pthread_cleanup_push(free, data); ctx->function(ctx->object); pthread_cleanup_pop(1); return NULL; } bool of_thread_attr_init(of_thread_attr_t *attr) { pthread_attr_t pattr; if (pthread_attr_init(&pattr) != 0) |
︙ | ︙ | |||
48 49 50 51 52 53 54 | pthread_attr_destroy(&pattr); } return true; } bool | | > > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | pthread_attr_destroy(&pattr); } return true; } bool of_thread_new(of_thread_t *thread, void (*function)(id), id object, const of_thread_attr_t *attr) { bool ret; pthread_attr_t pattr; if (pthread_attr_init(&pattr) != 0) return false; @try { struct thread_ctx *ctx; if (attr != NULL) { int policy, minPrio, maxPrio; struct sched_param param; if (attr->priority < 0 || attr->priority > 1) return false; |
︙ | ︙ | |||
85 86 87 88 89 90 91 92 93 | if (pthread_attr_setschedparam(&pattr, ¶m) != 0) return false; if (pthread_attr_setstacksize(&pattr, attr->stackSize) != 0) return false; } ret = (pthread_create(thread, &pattr, | > > > > > > | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | if (pthread_attr_setschedparam(&pattr, ¶m) != 0) return false; if (pthread_attr_setstacksize(&pattr, attr->stackSize) != 0) return false; } if ((ctx = malloc(sizeof(*ctx))) == NULL) return false; ctx->function = function; ctx->object = object; ret = (pthread_create(thread, &pattr, function_wrapper, ctx) == 0); } @finally { pthread_attr_destroy(&pattr); } return ret; } |
︙ | ︙ |
Modified src/threading_winapi.m from [73d2b0526d] to [b5d0945c6a].
︙ | ︙ | |||
22 23 24 25 26 27 28 | (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_LOWEST); attr->stackSize = 0; return true; } bool | | | | 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 |
︙ | ︙ |