merges IOSAD-50 into default
authorbuff <andreas@pep-project.org>
Fri, 20 Oct 2017 00:23:36 +0200
changeset 289bbe4e8da3568
parent 285 2ba534b9bc59
parent 288 a96780f56daa
child 291 1d64f8889d2c
merges IOSAD-50 into default
pEpObjCAdapter/PEPSession.h
pEpObjCAdapter/PEPSession.m
     1.1 --- a/pEpObjCAdapter/PEPSession.h	Thu Oct 19 11:07:32 2017 +0200
     1.2 +++ b/pEpObjCAdapter/PEPSession.h	Fri Oct 20 00:23:36 2017 +0200
     1.3 @@ -24,6 +24,8 @@
     1.4  
     1.5   Note: You must call `cleanup()` once before your process gets terminated to be able to gracefully shutdown.
     1.6   It is the clients responsibility not to make any calls to PEPSession after calling cleanup.
     1.7 +
     1.8 + Also: The Engine requires that the first session is created on the main thread. It is the responibility of the client to call PEPSession init once on the main thread before any other thread is calling it.
     1.9   */
    1.10  @interface PEPSession : NSObject
    1.11  
     2.1 --- a/pEpObjCAdapter/PEPSession.m	Thu Oct 19 11:07:32 2017 +0200
     2.2 +++ b/pEpObjCAdapter/PEPSession.m	Fri Oct 20 00:23:36 2017 +0200
     2.3 @@ -15,6 +15,16 @@
     2.4  
     2.5  #pragma mark - Public API
     2.6  
     2.7 +- (instancetype)init
     2.8 +{
     2.9 +    self = [super init];
    2.10 +    if (self) {
    2.11 +        // Trigger provider to make sure a internal session is kept for the current thread.
    2.12 +        [PEPSessionProvider session];
    2.13 +    }
    2.14 +    return self;
    2.15 +}
    2.16 +
    2.17  - (void)cleanup
    2.18  {
    2.19      [PEPSessionProvider cleanup];
     3.1 --- a/pEpObjCAdapter/PEPSessionProvider.m	Thu Oct 19 11:07:32 2017 +0200
     3.2 +++ b/pEpObjCAdapter/PEPSessionProvider.m	Fri Oct 20 00:23:36 2017 +0200
     3.3 @@ -11,7 +11,6 @@
     3.4  #import "PEPInternalSession.h"
     3.5  #import "PEPCopyableThread.h"
     3.6  
     3.7 -
     3.8  /**
     3.9   Restricts access to PEPInternalSession init to the one and only PEPSessionProvider. 
    3.10   */
    3.11 @@ -30,16 +29,22 @@
    3.12  {
    3.13      [[self sessionForThreadLock] lock];
    3.14  
    3.15 +    NSMutableDictionary<PEPCopyableThread*,PEPInternalSession*> *dict = [self sessionForThreadDict];
    3.16      PEPCopyableThread *currentThread = [[PEPCopyableThread alloc] initWithThread:[NSThread currentThread]];
    3.17 -    NSMutableDictionary<PEPCopyableThread*,PEPInternalSession*> *dict = [self sessionForThreadDict];
    3.18      PEPInternalSession *session = dict[currentThread];
    3.19      if (!session) {
    3.20          session = [[PEPInternalSession alloc] initInternal];
    3.21          dict[currentThread] = session;
    3.22      }
    3.23      [self nullifySessionsOfFinishedThreads];
    3.24 -//    NSLog(@"#################\nnum sessions is now %lu\n#################",
    3.25 +
    3.26 +//    NSLog(@"#################\nnum sessions is now %lu",
    3.27  //          (unsigned long)[self sessionForThreadDict].count);
    3.28 +//    NSLog(@"Threads:");
    3.29 +//    for (PEPCopyableThread *thread in dict.allKeys) {
    3.30 +//        NSLog(@"%@", thread.description);
    3.31 +//    }
    3.32 +//    NSLog(@"##################################");
    3.33  
    3.34      [[self sessionForThreadLock] unlock];
    3.35  
    3.36 @@ -84,9 +89,8 @@
    3.37      for (PEPCopyableThread *thread in dict.allKeys) {
    3.38          [self nullifySessionForThread:thread];
    3.39      }
    3.40 +    [dict removeAllObjects];
    3.41  //    NSLog(@"All sessions have been cleaned up. Session count is %lu", (unsigned long)dict.count);
    3.42 -    [dict removeAllObjects];
    3.43 -
    3.44  }
    3.45  
    3.46  /**