Overview
| Comment: | OFThread: Fix setting the name on the wrong thread
The name of the thread may only be set from the thread itself. So the |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | 0.90 |
| Files: | files | file ages | folders |
| SHA3-256: |
1d0042a0406ef262acc45a17ae57c5ad |
| User & Date: | js on 2017-10-07 10:46:59 |
| Other Links: | branch diff | manifest | tags |
Context
|
2017-10-07
| ||
| 10:50 | OFThread: Mark the thread block nullable (check-in: ead26485f6 user: js tags: 0.90) | |
| 10:46 | OFThread: Fix setting the name on the wrong thread (check-in: 1d0042a040 user: js tags: 0.90) | |
|
2017-10-01
| ||
| 21:13 | Fix testing the wrong OFKernelEventObserver (check-in: 13025565d3 user: js tags: 0.90) | |
Changes
Modified src/OFThread.h from [8bc0990f48] to [c358f93979].
| ︙ | ︙ | |||
73 74 75 76 77 78 79 80 81 82 83 84 85 86 | id _returnValue; OFRunLoop *_Nullable _runLoop; OFMutableDictionary *_threadDictionary; @private OFString *_Nullable _name; } #ifdef OF_HAVE_BLOCKS /*! * The block to execute in the thread. */ @property (readonly, nonatomic) of_thread_block_t threadBlock; #endif | > > > > > | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | id _returnValue; OFRunLoop *_Nullable _runLoop; OFMutableDictionary *_threadDictionary; @private OFString *_Nullable _name; } /*! * The name for the thread to use when starting it. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *name; #ifdef OF_HAVE_BLOCKS /*! * The block to execute in the thread. */ @property (readonly, nonatomic) of_thread_block_t threadBlock; #endif |
| ︙ | ︙ | |||
198 199 200 201 202 203 204 | /*! * @brief Returns the run loop for the thread. * * @return The run loop for the thread */ - (OFRunLoop *)runLoop; | < < < < < < < < < < < < < < | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | /*! * @brief Returns the run loop for the thread. * * @return The run loop for the thread */ - (OFRunLoop *)runLoop; /*! * @brief Returns the priority of the thread. * * This is a value between -1.0 (meaning lowest priority that still schedules) * and +1.0 (meaning highest priority that still allows getting preempted) * with normal priority being 0.0 (meaning being the same as the main thread). * |
| ︙ | ︙ |
Modified src/OFThread.m from [3ff1e2b592] to [e0cab8357e].
| ︙ | ︙ | |||
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
[thread release];
}
#endif
@implementation OFThread
#ifdef OF_HAVE_THREADS
# ifdef OF_HAVE_BLOCKS
@synthesize threadBlock = _threadBlock;
# endif
+ (void)initialize
{
if (self != [OFThread class])
| > | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
[thread release];
}
#endif
@implementation OFThread
#ifdef OF_HAVE_THREADS
@synthesize name = _name;
# ifdef OF_HAVE_BLOCKS
@synthesize threadBlock = _threadBlock;
# endif
+ (void)initialize
{
if (self != [OFThread class])
|
| ︙ | ︙ | |||
347 348 349 350 351 352 353 |
if (!of_thread_new(&_thread, callMain, self, &_attr)) {
[self release];
@throw [OFThreadStartFailedException exceptionWithThread: self];
}
if (_name != nil)
| | | | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
if (!of_thread_new(&_thread, callMain, self, &_attr)) {
[self release];
@throw [OFThreadStartFailedException exceptionWithThread: self];
}
if (_name != nil)
of_thread_set_name([_name UTF8String]);
else
of_thread_set_name(class_getName([self class]));
}
- (id)join
{
if (_running == OF_THREAD_NOT_RUNNING || !of_thread_join(_thread))
@throw [OFThreadJoinFailedException exceptionWithThread: self];
|
| ︙ | ︙ | |||
386 387 388 389 390 391 392 | _runLoop = [[OFRunLoop alloc] init]; } # endif return _runLoop; } | < < < < < < < < < < < < < < < < | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
_runLoop = [[OFRunLoop alloc] init];
}
# endif
return _runLoop;
}
- (float)priority
{
return _attr.priority;
}
- (void)setPriority: (float)priority
{
|
| ︙ | ︙ |
Modified src/threading.h from [44065a1e75] to [46db014c33].
| ︙ | ︙ | |||
96 97 98 99 100 101 102 |
# 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);
| | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# 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(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_FUNC of_thread_exit(void);
extern void of_once(of_once_t *control, void (*func)(void));
extern bool of_tlskey_new(of_tlskey_t *key);
extern bool of_tlskey_free(of_tlskey_t key);
extern bool of_mutex_new(of_mutex_t *mutex);
|
| ︙ | ︙ |
Modified src/threading_pthread.m from [9d56adf88b] to [7c690c290a].
| ︙ | ︙ | |||
171 172 173 174 175 176 177 |
{
pthread_exit(NULL);
OF_UNREACHABLE
}
void
| | | | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
{
pthread_exit(NULL);
OF_UNREACHABLE
}
void
of_thread_set_name(const char *name)
{
#if defined(OF_HAIKU)
rename_thread(find_thread(NULL), name);
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(pthread_self(), name);
#elif defined(HAVE_PTHREAD_SETNAME_NP)
# if defined(OF_MACOS) || defined(OF_IOS)
pthread_setname_np(name);
# elif defined(__GLIBC__)
char buffer[16];
|
| ︙ | ︙ |
Modified src/threading_winapi.m from [f624bdcb51] to [5f1546849f].
| ︙ | ︙ | |||
82 83 84 85 86 87 88 |
{
ExitThread(0);
OF_UNREACHABLE
}
void
| | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
{
ExitThread(0);
OF_UNREACHABLE
}
void
of_thread_set_name(const char *name)
{
}
bool
of_tlskey_new(of_tlskey_t *key)
{
return ((*key = TlsAlloc()) != TLS_OUT_OF_INDEXES);
|
| ︙ | ︙ |