ObjFW  Check-in [8a2fa8eff4]

Overview
Comment:Add +[OFThread isMainThread]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8a2fa8eff496010ce3d90a6c9d0b9310b8f6dc9e17f295d014c3fd1262951269
User & Date: js on 2019-09-01 18:22:55
Other Links: manifest | tags
Context
2019-09-01
18:25
Disallow +[OFThread terminate] on main thread check-in: 35958b2528 user: js tags: trunk
18:22
Add +[OFThread isMainThread] check-in: 8a2fa8eff4 user: js tags: trunk
16:53
Remove remaining uses of lrint() check-in: e702135e17 user: js tags: trunk
Changes

Modified src/OFThread.h from [f242100e35] to [f2bf600216].

93
94
95
96
97
98
99

100
101
102
103
104
105
106
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107







+







}
#endif

#ifdef OF_HAVE_CLASS_PROPERTIES
# ifdef OF_HAVE_THREADS
@property (class, readonly, nullable, nonatomic) OFThread *currentThread;
@property (class, readonly, nullable, nonatomic) OFThread *mainThread;
@property (class, readonly, nonatomic) bool isMainThread;
@property (class, readonly, nullable, nonatomic)
    OFMutableDictionary *threadDictionary;
@property (class, nullable, copy, nonatomic) OFString *name;
# endif
# ifdef OF_HAVE_SOCKETS
@property (class, readonly, nonatomic) OFDNSResolver *DNSResolver;
# endif
184
185
186
187
188
189
190







191
192
193
194
195
196
197
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205







+
+
+
+
+
+
+







/*!
 * @brief Returns the main thread.
 *
 * @return The main thread
 */
+ (nullable OFThread *)mainThread;

/*!
 * @brief Returns whether the current thread is the main thread.
 *
 * @return Whether the current thread is the main thread.
 */
+ (bool)isMainThread;

/*!
 * @brief Returns a dictionary to store thread-specific data, meaning it
 *	  returns a different dictionary for every thread.
 *
 * @return A dictionary to store thread-specific data
 */
+ (nullable OFMutableDictionary *)threadDictionary;

Modified src/OFThread.m from [590ace3cab] to [4ed6327174].

186
187
188
189
190
191
192








193
194
195
196
197
198
199
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207







+
+
+
+
+
+
+
+







	return of_tlskey_get(threadSelfKey);
}

+ (OFThread *)mainThread
{
	return mainThread;
}

+ (bool)isMainThread
{
	if (mainThread == nil)
		return false;

	return (of_tlskey_get(threadSelfKey) == mainThread);
}

+ (OFMutableDictionary *)threadDictionary
{
	OFThread *thread = of_tlskey_get(threadSelfKey);

	if (thread == nil)
		return nil;