You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2017/04/10 05:53:53 UTC

[03/15] incubator-weex git commit: * [ios] remove NSTextStorage lock because it is not necessary for thread safety

* [ios] remove NSTextStorage lock because it is not necessary for thread safety


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/dbe2f321
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/dbe2f321
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/dbe2f321

Branch: refs/heads/0.12-dev
Commit: dbe2f321bc37fc308c3b75ef8c48d77b7a4b17be
Parents: 82412d7
Author: \u9690\u98ce <cx...@apache.org>
Authored: Wed Apr 5 17:50:47 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Wed Apr 5 17:50:47 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXTextComponent.m | 46 +-------------------
 1 file changed, 1 insertion(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dbe2f321/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index f18ac94..77e7ce2 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -119,16 +119,6 @@
     WXTextDecoration _textDecoration;
     NSString *_textOverflow;
     CGFloat _lineHeight;
-    
-   
-    pthread_mutex_t _textStorageMutex;
-    pthread_mutexattr_t _textStorageMutexAttr;
-}
-
-static BOOL _isUsingTextStorageLock = NO;
-+ (void)useTextStorageLock:(BOOL)isUsingTextStorageLock
-{
-    _isUsingTextStorageLock = isUsingTextStorageLock;
 }
 
 - (instancetype)initWithRef:(NSString *)ref
@@ -140,12 +130,6 @@ static BOOL _isUsingTextStorageLock = NO;
 {
     self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance];
     if (self) {
-        if (_isUsingTextStorageLock) {
-            pthread_mutexattr_init(&_textStorageMutexAttr);
-            pthread_mutexattr_settype(&_textStorageMutexAttr, PTHREAD_MUTEX_RECURSIVE);
-            pthread_mutex_init(&_textStorageMutex, &_textStorageMutexAttr);
-        }
-        
         [self fillCSSStyles:styles];
         [self fillAttributes:attributes];
     }
@@ -155,10 +139,6 @@ static BOOL _isUsingTextStorageLock = NO;
 
 - (void)dealloc
 {
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_destroy(&_textStorageMutex);
-        pthread_mutexattr_destroy(&_textStorageMutexAttr);
-    }
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 
@@ -226,13 +206,7 @@ do {\
 
 - (void)setNeedsRepaint
 {
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_lock(&_textStorageMutex);
-    }
     _textStorage = nil;
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_unlock(&_textStorageMutex);
-    }
 }
 
 #pragma mark - Subclass
@@ -244,13 +218,7 @@ do {\
 
 - (void)viewDidLoad
 {
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_lock(&_textStorageMutex);
-    }
     ((WXText *)self.view).textStorage = _textStorage;
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_unlock(&_textStorageMutex);
-    }
     [self setNeedsDisplay];
 }
 
@@ -435,14 +403,7 @@ do {\
     [layoutManager ensureLayoutForTextContainer:textContainer];
     
     _textStorageWidth = width;
-    
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_lock(&_textStorageMutex);
-    }
     _textStorage = textStorage;
-    if (_isUsingTextStorageLock) {
-        pthread_mutex_unlock(&_textStorageMutex);
-    }
     
     return textStorage;
 }
@@ -454,13 +415,8 @@ do {\
     
     [self.weexInstance.componentManager  _addUITask:^{
         if ([self isViewLoaded]) {
-            if (_isUsingTextStorageLock) {
-                pthread_mutex_lock(&_textStorageMutex);
-            }
             ((WXText *)self.view).textStorage = textStorage;
-            if (_isUsingTextStorageLock) {
-                pthread_mutex_unlock(&_textStorageMutex);
-            }
+            
             [self readyToRender]; // notify super component
             [self setNeedsDisplay];
         }