Index: ObjFW.xcodeproj/project.pbxproj ================================================================== --- ObjFW.xcodeproj/project.pbxproj +++ ObjFW.xcodeproj/project.pbxproj @@ -279,12 +279,10 @@ 4B674402163C395900EB1E59 /* OFLocking.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6743F9163C395900EB1E59 /* OFLocking.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B674403163C395900EB1E59 /* OFMutex.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6743FA163C395900EB1E59 /* OFMutex.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B674404163C395900EB1E59 /* OFMutex.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6743FB163C395900EB1E59 /* OFMutex.m */; }; 4B674405163C395900EB1E59 /* OFRecursiveMutex.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6743FC163C395900EB1E59 /* OFRecursiveMutex.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B674406163C395900EB1E59 /* OFRecursiveMutex.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6743FD163C395900EB1E59 /* OFRecursiveMutex.m */; }; - 4B674407163C395900EB1E59 /* OFTLSKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6743FE163C395900EB1E59 /* OFTLSKey.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4B674408163C395900EB1E59 /* OFTLSKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6743FF163C395900EB1E59 /* OFTLSKey.m */; }; 4B745BA5168B25E600A6C20E /* OFSystemInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B745BA3168B25E600A6C20E /* OFSystemInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B745BA6168B25E600A6C20E /* OFSystemInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B745BA4168B25E600A6C20E /* OFSystemInfo.m */; }; 4B7FF3B4133CED6200000324 /* OFConditionStillWaitingException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B7FF3B2133CED6100000324 /* OFConditionStillWaitingException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B7FF3B5133CED6200000324 /* OFConditionStillWaitingException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B7FF3B3133CED6100000324 /* OFConditionStillWaitingException.m */; }; 4B837D7916829C5F007A3E83 /* block.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B837D7716829C5F007A3E83 /* block.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -344,11 +342,10 @@ 4BB25E89139C388A00F574EA /* OFObject+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB25E83139C388A00F574EA /* OFObject+Serialization.m */; }; 4BB25E8A139C388A00F574EA /* OFString+Serialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB25E84139C388A00F574EA /* OFString+Serialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BB25E8B139C388A00F574EA /* OFString+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB25E85139C388A00F574EA /* OFString+Serialization.m */; }; 4BB25E8C139C388A00F574EA /* OFXMLElement+Serialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB25E86139C388A00F574EA /* OFXMLElement+Serialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BB25E8D139C388A00F574EA /* OFXMLElement+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB25E87139C388A00F574EA /* OFXMLElement+Serialization.m */; }; - 4BB4B54316775FF4002A2DCE /* apple-forwarding.S in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4B53E16775FF4002A2DCE /* apple-forwarding.S */; }; 4BB4B54416775FF4002A2DCE /* OFHTTPClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB4B53F16775FF4002A2DCE /* OFHTTPClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BB4B54516775FF4002A2DCE /* OFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4B54016775FF4002A2DCE /* OFHTTPClient.m */; }; 4BB4B54616775FF4002A2DCE /* OFHTTPServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB4B54116775FF4002A2DCE /* OFHTTPServer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BB4B54716775FF4002A2DCE /* OFHTTPServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4B54216775FF4002A2DCE /* OFHTTPServer.m */; }; 4BB4B54A16776094002A2DCE /* OFHTTPClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4B54916776094002A2DCE /* OFHTTPClientTests.m */; }; @@ -362,10 +359,11 @@ 4BD653C6143B8489006182F0 /* OFTCPSocket+SOCKS5.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */; }; 4BD77FDE176E4BC40031C497 /* OFUnboundPrefixException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD77FDC176E4BC40031C497 /* OFUnboundPrefixException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BD77FDF176E4BC40031C497 /* OFUnboundPrefixException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD77FDD176E4BC40031C497 /* OFUnboundPrefixException.m */; }; 4BD98C03133814220048DD5B /* objfw-defs.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD98C011338140B0048DD5B /* objfw-defs.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BDF37B51338055600F9A81A /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDF37B41338055600F9A81A /* config.h */; }; + 4BEF2D3117A5BF5200BB8BA3 /* forwarding.S in Sources */ = {isa = PBXBuildFile; fileRef = 4BEF2D3017A5BF5200BB8BA3 /* forwarding.S */; }; 4BF33AFB133807590059CEF7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B3D23761337FBC800DD29B8 /* ObjFW.framework */; }; 4BF33AFC133807A20059CEF7 /* OFArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66E1235358D0076B512 /* OFArrayTests.m */; }; 4BF33AFD133807A20059CEF7 /* OFBlockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E412DF4259005C7A0C /* OFBlockTests.m */; }; 4BF33AFE133807A20059CEF7 /* OFDataArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66F1235358D0076B512 /* OFDataArrayTests.m */; }; 4BF33AFF133807A20059CEF7 /* OFDateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E512DF4259005C7A0C /* OFDateTests.m */; }; @@ -628,12 +626,10 @@ 4B6743F9163C395900EB1E59 /* OFLocking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFLocking.h; path = src/OFLocking.h; sourceTree = ""; }; 4B6743FA163C395900EB1E59 /* OFMutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutex.h; path = src/OFMutex.h; sourceTree = ""; }; 4B6743FB163C395900EB1E59 /* OFMutex.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutex.m; path = src/OFMutex.m; sourceTree = ""; }; 4B6743FC163C395900EB1E59 /* OFRecursiveMutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFRecursiveMutex.h; path = src/OFRecursiveMutex.h; sourceTree = ""; }; 4B6743FD163C395900EB1E59 /* OFRecursiveMutex.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRecursiveMutex.m; path = src/OFRecursiveMutex.m; sourceTree = ""; }; - 4B6743FE163C395900EB1E59 /* OFTLSKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFTLSKey.h; path = src/OFTLSKey.h; sourceTree = ""; }; - 4B6743FF163C395900EB1E59 /* OFTLSKey.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFTLSKey.m; path = src/OFTLSKey.m; sourceTree = ""; }; 4B6799561099E7C50041064A /* asprintf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = asprintf.h; path = src/asprintf.h; sourceTree = ""; }; 4B67995A1099E7C50041064A /* OFArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFArray.h; path = src/OFArray.h; sourceTree = ""; }; 4B67995B1099E7C50041064A /* OFArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFArray.m; path = src/OFArray.m; sourceTree = ""; }; 4B67995C1099E7C50041064A /* OFAutoreleasePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFAutoreleasePool.h; path = src/OFAutoreleasePool.h; sourceTree = ""; }; 4B67995D1099E7C50041064A /* OFAutoreleasePool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFAutoreleasePool.m; path = src/OFAutoreleasePool.m; sourceTree = ""; }; @@ -768,11 +764,10 @@ 4BB25E83139C388A00F574EA /* OFObject+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFObject+Serialization.m"; path = "src/OFObject+Serialization.m"; sourceTree = ""; }; 4BB25E84139C388A00F574EA /* OFString+Serialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFString+Serialization.h"; path = "src/OFString+Serialization.h"; sourceTree = ""; }; 4BB25E85139C388A00F574EA /* OFString+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFString+Serialization.m"; path = "src/OFString+Serialization.m"; sourceTree = ""; }; 4BB25E86139C388A00F574EA /* OFXMLElement+Serialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFXMLElement+Serialization.h"; path = "src/OFXMLElement+Serialization.h"; sourceTree = ""; }; 4BB25E87139C388A00F574EA /* OFXMLElement+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFXMLElement+Serialization.m"; path = "src/OFXMLElement+Serialization.m"; sourceTree = ""; }; - 4BB4B53E16775FF4002A2DCE /* apple-forwarding.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = "apple-forwarding.S"; path = "src/apple-forwarding.S"; sourceTree = ""; }; 4BB4B53F16775FF4002A2DCE /* OFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFHTTPClient.h; path = src/OFHTTPClient.h; sourceTree = ""; }; 4BB4B54016775FF4002A2DCE /* OFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFHTTPClient.m; path = src/OFHTTPClient.m; sourceTree = ""; }; 4BB4B54116775FF4002A2DCE /* OFHTTPServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFHTTPServer.h; path = src/OFHTTPServer.h; sourceTree = ""; }; 4BB4B54216775FF4002A2DCE /* OFHTTPServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFHTTPServer.m; path = src/OFHTTPServer.m; sourceTree = ""; }; 4BB4B54916776094002A2DCE /* OFHTTPClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFHTTPClientTests.m; path = tests/OFHTTPClientTests.m; sourceTree = ""; }; @@ -801,10 +796,11 @@ 4BE5F0D812DF4225005C7A0C /* OFConstantString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConstantString.m; path = src/OFConstantString.m; sourceTree = SOURCE_ROOT; }; 4BE5F0D912DF4225005C7A0C /* OFDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFDate.h; path = src/OFDate.h; sourceTree = SOURCE_ROOT; }; 4BE5F0DA12DF4225005C7A0C /* OFDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFDate.m; path = src/OFDate.m; sourceTree = SOURCE_ROOT; }; 4BE5F0E412DF4259005C7A0C /* OFBlockTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBlockTests.m; path = tests/OFBlockTests.m; sourceTree = SOURCE_ROOT; }; 4BE5F0E512DF4259005C7A0C /* OFDateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFDateTests.m; path = tests/OFDateTests.m; sourceTree = SOURCE_ROOT; }; + 4BEF2D3017A5BF5200BB8BA3 /* forwarding.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = forwarding.S; path = src/forwarding.S; sourceTree = ""; }; 4BF0749512DFAFCA00A4ADD1 /* OFURLTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFURLTests.m; path = tests/OFURLTests.m; sourceTree = SOURCE_ROOT; }; 4BF1BCBF11C9663F0025511F /* objfw-defs.h.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "objfw-defs.h.in"; path = "src/objfw-defs.h.in"; sourceTree = ""; }; 4BF1BCC011C9663F0025511F /* OFHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFHash.h; path = src/OFHash.h; sourceTree = ""; }; 4BF1BCC211C9663F0025511F /* OFMD5Hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMD5Hash.h; path = src/OFMD5Hash.h; sourceTree = ""; }; 4BF1BCC311C9663F0025511F /* OFMD5Hash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMD5Hash.m; path = src/OFMD5Hash.m; sourceTree = ""; }; @@ -1217,12 +1213,10 @@ 4B6799841099E7C50041064A /* OFThread.m */, 4B9361A61511000C00DCD16B /* OFThreadPool.h */, 4B9361A71511000C00DCD16B /* OFThreadPool.m */, 4B325EDB1605F3A0007836CA /* OFTimer.h */, 4B325EDC1605F3A0007836CA /* OFTimer.m */, - 4B6743FE163C395900EB1E59 /* OFTLSKey.h */, - 4B6743FF163C395900EB1E59 /* OFTLSKey.m */, 4BA02BA015041F5900002F84 /* OFTLSSocket.h */, 4B4A61F212DF5EA20048F3F2 /* OFURL.h */, 4B4A61F312DF5EA20048F3F2 /* OFURL.m */, 4BF1BCCE11C9663F0025511F /* OFXMLAttribute.h */, 4BF1BCCF11C9663F0025511F /* OFXMLAttribute.m */, @@ -1243,20 +1237,20 @@ 4B6799891099E7C50041064A /* OFXMLParser.h */, 4B67998A1099E7C50041064A /* OFXMLParser.m */, 4B48B95214DC23B100546D39 /* OFXMLProcessingInstructions.h */, 4B48B95314DC23B100546D39 /* OFXMLProcessingInstructions.m */, 4B6AF97310A8D4450003FB0A /* ObjFW.h */, - 4BB4B53E16775FF4002A2DCE /* apple-forwarding.S */, 4B6799561099E7C50041064A /* asprintf.h */, 4B6AF96C10A8D3E40003FB0A /* asprintf.m */, 4BBA36C411406AB700CBA3AC /* atomic.h */, 4BA9CFA315E129D30076DC74 /* autorelease.h */, 4B3D236D1337FB5800DD29B8 /* base64.h */, 4B3D236E1337FB5800DD29B8 /* base64.m */, 4B837D7716829C5F007A3E83 /* block.h */, 4B837D7816829C5F007A3E83 /* instance.h */, 4B6AF96F10A8D40E0003FB0A /* iso_8859_15.m */, + 4BEF2D3017A5BF5200BB8BA3 /* forwarding.S */, 4BE17AD812FD744C002CEB0B /* foundation-compat.m */, 4BBA36C511406AB700CBA3AC /* macros.h */, 4BF1BCBF11C9663F0025511F /* objfw-defs.h.in */, 4BB50DCF12F863C700C9393F /* of_asprintf.h */, 4BB50DD012F863C700C9393F /* of_asprintf.m */, @@ -1439,11 +1433,10 @@ 4B745BA5168B25E600A6C20E /* OFSystemInfo.h in Headers */, 4B3D23DD1337FCB000DD29B8 /* OFTCPSocket.h in Headers */, 4B3D23DE1337FCB000DD29B8 /* OFThread.h in Headers */, 4B9361A81511000C00DCD16B /* OFThreadPool.h in Headers */, 4B325EDF1605F3A0007836CA /* OFTimer.h in Headers */, - 4B674407163C395900EB1E59 /* OFTLSKey.h in Headers */, 4BA02BA215041F5900002F84 /* OFTLSSocket.h in Headers */, 4B3D23DF1337FCB000DD29B8 /* OFURL.h in Headers */, 4B3D23E01337FCB000DD29B8 /* OFXMLAttribute.h in Headers */, 4B49EA6D143B3A090005BBC6 /* OFXMLCDATA.h in Headers */, 4B49EA6F143B3A090005BBC6 /* OFXMLCharacters.h in Headers */, @@ -1797,11 +1790,10 @@ 4B3D23AB1337FC0D00DD29B8 /* OFTCPSocket.m in Sources */, 4BD653C6143B8489006182F0 /* OFTCPSocket+SOCKS5.m in Sources */, 4B3D23AC1337FC0D00DD29B8 /* OFThread.m in Sources */, 4B9361A91511000C00DCD16B /* OFThreadPool.m in Sources */, 4B325EE01605F3A0007836CA /* OFTimer.m in Sources */, - 4B674408163C395900EB1E59 /* OFTLSKey.m in Sources */, 4B3D23AD1337FC0D00DD29B8 /* OFURL.m in Sources */, 4B3D23AE1337FC0D00DD29B8 /* OFXMLAttribute.m in Sources */, 4B49EA6E143B3A090005BBC6 /* OFXMLCDATA.m in Sources */, 4B49EA70143B3A090005BBC6 /* OFXMLCharacters.m in Sources */, 4B49EA72143B3A090005BBC6 /* OFXMLComment.m in Sources */, @@ -1809,13 +1801,13 @@ 4BB25E8D139C388A00F574EA /* OFXMLElement+Serialization.m in Sources */, 4B3D23B01337FC0D00DD29B8 /* OFXMLElementBuilder.m in Sources */, 4B11005D14329B9A003A45D8 /* OFXMLNode.m in Sources */, 4B3D23B11337FC0D00DD29B8 /* OFXMLParser.m in Sources */, 4B48B95514DC23B100546D39 /* OFXMLProcessingInstructions.m in Sources */, - 4BB4B54316775FF4002A2DCE /* apple-forwarding.S in Sources */, 4B3D23B31337FC0D00DD29B8 /* base64.m in Sources */, 4B3D23B41337FC0D00DD29B8 /* iso_8859_15.m in Sources */, + 4BEF2D3117A5BF5200BB8BA3 /* forwarding.S in Sources */, 4B3D23B51337FC0D00DD29B8 /* foundation-compat.m in Sources */, 4B3D23EE1337FFD000DD29B8 /* of_asprintf.m in Sources */, 4BA355BA14879BDD00442EF4 /* of_strptime.m in Sources */, 4B3D23B91337FC0D00DD29B8 /* unicode.m in Sources */, 4B3D23BA1337FC0D00DD29B8 /* windows_1252.m in Sources */, Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -79,12 +79,11 @@ OFStreamSocket.m \ OFTCPSocket.m SRCS_THREADS = OFCondition.m \ OFMutex.m \ OFRecursiveMutex.m \ - OFThreadPool.m \ - OFTLSKey.m + OFThreadPool.m INCLUDES_THREADS = threading.h INCLUDES := ${SRCS:.m=.h} \ OFCollection.h \ OFHash.h \ DELETED src/OFTLSKey.h Index: src/OFTLSKey.h ================================================================== --- src/OFTLSKey.h +++ src/OFTLSKey.h @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * 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. - */ - -#import "OFObject.h" -#import "OFList.h" - -#import "threading.h" - -/* Haiku used to define this for some unknown reason which causes trouble */ -#ifdef protected -# undef protected -#endif - -/*! - * @brief A class for Thread Local Storage keys. - */ -@interface OFTLSKey: OFObject -{ -@public - of_tlskey_t _key; -@protected - void (*_destructor)(id); - of_list_object_t *_listObject; - bool _initialized; -} - -/*! - * @brief Creates a new Thread Local Storage key - * - * @return A new, autoreleased Thread Local Storage key - */ -+ (instancetype)TLSKey; - -/*! - * @brief Creates a new Thread Local Storage key with the specified destructor. - * - * @param destructor A destructor that is called when a thread is terminated. - * The argument for the destructor is the TLS key. - * @return A new autoreleased Thread Local Storage key - */ -+ (instancetype)TLSKeyWithDestructor: (void(*)(id))destructor; - -+ (void)OF_callAllDestructors; - -/*! - * @brief Initializes an already allocated Thread Local Storage Key with the - * specified destructor. - * - * @param destructor A destructor that is called when a thread is terminated. - * The argument for the destructor is the TLS key. - * @return An initialized Thread Local Storage key - */ -- initWithDestructor: (void(*)(id))destructor; -@end DELETED src/OFTLSKey.m Index: src/OFTLSKey.m ================================================================== --- src/OFTLSKey.m +++ src/OFTLSKey.m @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * 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. - */ - -#include "config.h" - -#import "OFTLSKey.h" - -#import "OFInitializationFailedException.h" - -static OFList *TLSKeys; - -@implementation OFTLSKey -+ (void)initialize -{ - if (self == [OFTLSKey class]) - TLSKeys = [[OFList alloc] init]; -} - -+ (instancetype)TLSKey -{ - return [[[self alloc] init] autorelease]; -} - -+ (instancetype)TLSKeyWithDestructor: (void(*)(id))destructor -{ - return [[[self alloc] initWithDestructor: destructor] autorelease]; -} - -+ (void)OF_callAllDestructors -{ - of_list_object_t *iter; - - @synchronized (TLSKeys) { - for (iter = [TLSKeys firstListObject]; iter != NULL; - iter = iter->next) { - OFTLSKey *key = (OFTLSKey*)iter->object; - - if (key->_destructor != NULL) - key->_destructor(iter->object); - } - } -} - -- init -{ - self = [super init]; - - @try { - if (!of_tlskey_new(&_key)) - @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; - - _initialized = true; - - @synchronized (TLSKeys) { - _listObject = [TLSKeys appendObject: self]; - } - } @catch (id e) { - [self release]; - @throw e; - } - - return self; -} - -- initWithDestructor: (void(*)(id))destructor -{ - self = [self init]; - - _destructor = destructor; - - return self; -} - -- (void)dealloc -{ - if (_initialized) { - if (_destructor != NULL) - _destructor(self); - - of_tlskey_free(_key); - } - - /* In case we called [self release] in init */ - if (_listObject != NULL) { - @synchronized (TLSKeys) { - [TLSKeys removeListObject: _listObject]; - } - } - - [super dealloc]; -} -@end Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -13,26 +13,20 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" + #ifdef OF_HAVE_THREADS -# import "OFTLSKey.h" - # import "threading.h" #endif -/* Haiku used to define this for some unknown reason which causes trouble */ -#ifdef protected -# undef protected -#endif - /*! @file */ @class OFDate; -@class OFSortedList; @class OFRunLoop; +@class OFMutableDictionary; #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_BLOCKS) /*! * @brief A block to be executed in a new thread. * @@ -71,10 +65,11 @@ of_thread_block_t _threadBlock; # endif id _returnValue; OFRunLoop *_runLoop; OFString *_name; + OFMutableDictionary *_threadDictionary; } # ifdef OF_HAVE_PROPERTIES # ifdef OF_HAVE_BLOCKS @property (copy) of_thread_block_t threadBlock; @@ -97,36 +92,10 @@ * @return A new, autoreleased thread */ + (instancetype)threadWithThreadBlock: (of_thread_block_t)threadBlock; # endif -/*! - * @brief Sets the Thread Local Storage for the specified key. - * - * 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 object The object the Thread Local Storage key will be set to - */ -+ (void)setObject: (id)object - forTLSKey: (OFTLSKey*)key; - -/*! - * @brief Returns the object for the specified Thread Local Storage key or nil - * if the key does not exist. - * - * @warning The returned object is *not* retained and autoreleased for - * performance reasons! - * - * @param key The Thread Local Storage key - * @return The object for the specified Thread Local Storage key or nil if the - * key does not exist. - */ -+ (id)objectForTLSKey: (OFTLSKey*)key; - /*! * @brief Returns the current thread. * * @return The current thread */ @@ -136,10 +105,18 @@ * @brief Returns the main thread. * * @return The main thread */ + (OFThread*)mainThread; + +/*! + * @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. + */ ++ (OFMutableDictionary*)threadDictionary; #endif /*! * @brief Suspends execution of the current thread for the specified time * interval. Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -39,11 +39,11 @@ #import "OFRunLoop.h" #import "OFThread.h" #import "OFList.h" #import "OFDate.h" -#import "OFSortedList.h" +#import "OFDictionary.h" #import "OFAutoreleasePool.h" #ifdef _WIN32 # include #endif @@ -93,11 +93,10 @@ [thread handleTermination]; thread->_running = OF_THREAD_WAITING_FOR_JOIN; - [OFTLSKey OF_callAllDestructors]; # ifdef OF_OBJFW_RUNTIME /* * As the values returned by objc_autoreleasePoolPush() in the ObjFW * runtime are not actually pointers, but sequential numbers, 0 means * we pop everything. @@ -151,36 +150,29 @@ { return [[[self alloc] initWithThreadBlock: threadBlock] autorelease]; } # endif -+ (void)setObject: (id)object - forTLSKey: (OFTLSKey*)key -{ - id oldObject = of_tlskey_get(key->_key); - - if (!of_tlskey_set(key->_key, [object retain])) - /* FIXME: Find a better exception */ - @throw [OFInvalidArgumentException exception]; - - [oldObject release]; -} - -+ (id)objectForTLSKey: (OFTLSKey*)key -{ - return [[(id)of_tlskey_get(key->_key) retain] autorelease]; -} - + (OFThread*)currentThread { - return [[(id)of_tlskey_get(threadSelfKey) retain] autorelease]; + return of_tlskey_get(threadSelfKey); } + (OFThread*)mainThread { return mainThread; } + ++ (OFMutableDictionary*)threadDictionary +{ + OFThread *thread = of_tlskey_get(threadSelfKey); + + if (thread->_threadDictionary == nil) + thread->_threadDictionary = [[OFMutableDictionary alloc] init]; + + return thread->_threadDictionary; +} #endif + (void)sleepForTimeInterval: (double)seconds { if (seconds < 0) @@ -240,11 +232,10 @@ [thread handleTermination]; thread->_running = OF_THREAD_WAITING_FOR_JOIN; } - [OFTLSKey OF_callAllDestructors]; # ifdef OF_OBJFW_RUNTIME /* * As the values returned by objc_autoreleasePoolPush() in the ObjFW * runtime are not actually pointers, but sequential numbers, 0 means * we pop everything. @@ -293,10 +284,13 @@ - (void)handleTermination { OFRunLoop *oldRunLoop = _runLoop; _runLoop = nil; [oldRunLoop release]; + + [_threadDictionary release]; + _threadDictionary = nil; } - (void)start { if (_running == OF_THREAD_RUNNING) @@ -379,11 +373,10 @@ */ if (_running == OF_THREAD_WAITING_FOR_JOIN) of_thread_detach(_thread); [_returnValue release]; - [_runLoop release]; # ifdef OF_HAVE_BLOCKS [_threadBlock release]; # endif [super dealloc]; Index: src/OFXMLElementBuilder.m ================================================================== --- src/OFXMLElementBuilder.m +++ src/OFXMLElementBuilder.m @@ -22,11 +22,11 @@ #import "OFXMLCharacters.h" #import "OFXMLCDATA.h" #import "OFXMLComment.h" #import "OFXMLProcessingInstructions.h" #import "OFXMLParser.h" -#import "OFMutableArray.h" +#import "OFArray.h" #import "OFMalformedXMLException.h" #import "macros.h" Index: tests/OFThreadTests.m ================================================================== --- tests/OFThreadTests.m +++ tests/OFThreadTests.m @@ -16,10 +16,11 @@ #include "config.h" #import "OFThread.h" #import "OFString.h" +#import "OFDictionary.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" static OFString *module = @"OFThread"; @@ -28,36 +29,31 @@ @end @implementation TestThread - (id)main { + [[OFThread threadDictionary] setObject: @"bar" + forKey: @"foo"]; + return @"success"; } @end @implementation TestsAppDelegate (OFThreadTests) - (void)threadTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; TestThread *t; - OFTLSKey *key; + OFMutableDictionary *d; TEST(@"+[thread]", (t = [TestThread thread])) TEST(@"-[start]", R([t start])) TEST(@"-[join]", [[t join] isEqual: @"success"]) - TEST(@"OFTLSKey's +[TLSKey]", (key = [OFTLSKey TLSKey])) - - TEST(@"+[setObject:forTLSKey:]", - R([OFThread setObject: @"setme" - forTLSKey: key]) && - R([OFThread setObject: @"foo" - forTLSKey: key])) - - TEST(@"+[objectForTLSKey:]", - [[OFThread objectForTLSKey: key] isEqual: @"foo"]) + TEST(@"-[threadDictionary]", (d = [OFThread threadDictionary]) && + [d objectForKey: @"foo"] == nil) [pool drain]; } @end