ObjFW  Check-in [e9e263d62a]

Overview
Comment:Fix missing retain + autorelease in TLS-object handling.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e9e263d62acab7bcf582b8d3cf215ff88777fae4b0729ea845a7b7cc315a3078
User & Date: js on 2011-01-11 22:43:35
Other Links: manifest | tags
Context
2011-01-11
22:45
Rename tlsKey -> TLSKey. Acronyms are always uppercase! check-in: eb374bb382 user: js tags: trunk
22:43
Fix missing retain + autorelease in TLS-object handling. check-in: e9e263d62a user: js tags: trunk
22:03
Replace -[sleepForNMilliseconds:] with -[sleepForTimeInterval:]. check-in: 219a630ef0 user: js tags: trunk
Changes

Modified src/OFThread.h from [fdc4c85c01] to [5c73dd92a3].

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 *
 * The specified object is first retained and then the object stored before is
 * released. You can specify nil as object if you want the old object to be
 * released and don't want any new object for the TLS key.
 *
 * \param key The Thread Local Storage key
 * \param obj The object the Thread Local Storage key will be set to
 * \return The old object, autoreleased
 */
+ (id)setObject: (id)obj
      forTLSKey: (OFTLSKey*)key;

/**
 * Returns the object for the specified Thread Local Storage key.
 *
 * The returned object is <i>not</i> retained and autoreleased for performance
 * reasons!
 *







<

|
|







89
90
91
92
93
94
95

96
97
98
99
100
101
102
103
104
105
 *
 * The specified object is first retained and then the object stored before is
 * released. You can specify nil as object if you want the old object to be
 * released and don't want any new object for the TLS key.
 *
 * \param key The Thread Local Storage key
 * \param obj The object the Thread Local Storage key will be set to

 */
+ (void)setObject: (id)obj
	forTLSKey: (OFTLSKey*)key;

/**
 * Returns the object for the specified Thread Local Storage key.
 *
 * The returned object is <i>not</i> retained and autoreleased for performance
 * reasons!
 *

Modified src/OFThread.m from [907c5a1a16] to [e6c064086f].

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
}

+ threadWithObject: (id)obj
{
	return [[[self alloc] initWithObject: obj] autorelease];
}

+ (id)setObject: (id)obj
      forTLSKey: (OFTLSKey*)key
{
	id old = of_tlskey_get(key->key);

	if (!of_tlskey_set(key->key, [obj retain]))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	return [old autorelease];
}

+ (id)objectForTLSKey: (OFTLSKey*)key
{
	return of_tlskey_get(key->key);
}

+ (OFThread*)currentThread
{
	return of_tlskey_get(thread_self);
}

+ (void)sleepForTimeInterval: (int64_t)sec
{
	if (sec < 0)
		@throw [OFOutOfRangeException newWithClass: self];








|
|







|




|




|







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
}

+ threadWithObject: (id)obj
{
	return [[[self alloc] initWithObject: obj] autorelease];
}

+ (void)setObject: (id)obj
	forTLSKey: (OFTLSKey*)key
{
	id old = of_tlskey_get(key->key);

	if (!of_tlskey_set(key->key, [obj retain]))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	[old release];
}

+ (id)objectForTLSKey: (OFTLSKey*)key
{
	return [[of_tlskey_get(key->key) retain] autorelease];
}

+ (OFThread*)currentThread
{
	return [[of_tlskey_get(thread_self) retain] autorelease];
}

+ (void)sleepForTimeInterval: (int64_t)sec
{
	if (sec < 0)
		@throw [OFOutOfRangeException newWithClass: self];