IOSAD-157 PEPQueue has prequeue (push to front) IOSAD-157
authorDirk Zimmermann <dz@pep.security>
Mon, 18 Nov 2019 15:54:57 +0100
branchIOSAD-157
changeset 1335708d2520d5ba
parent 1334 e5237f361e4f
child 1336 7b362fde775a
IOSAD-157 PEPQueue has prequeue (push to front)
pEpObjCAdapter/PEPQueue.h
pEpObjCAdapter/PEPQueue.m
     1.1 --- a/pEpObjCAdapter/PEPQueue.h	Mon Nov 18 15:54:57 2019 +0100
     1.2 +++ b/pEpObjCAdapter/PEPQueue.h	Mon Nov 18 15:54:57 2019 +0100
     1.3 @@ -18,6 +18,11 @@
     1.4  /// @param object The object to put into the queue.
     1.5  - (void)enqueue:(id)object;
     1.6  
     1.7 +/// Puts an object into the queue, so that it will be dequeued before the
     1.8 +/// existing objects.
     1.9 +/// @param object The object to put into the queue.
    1.10 +- (void)prequeue:(id)object;
    1.11 +
    1.12  - (id)timedDequeue:(time_t*)timeout;
    1.13  
    1.14  - (id)dequeue;
     2.1 --- a/pEpObjCAdapter/PEPQueue.m	Mon Nov 18 15:54:57 2019 +0100
     2.2 +++ b/pEpObjCAdapter/PEPQueue.m	Mon Nov 18 15:54:57 2019 +0100
     2.3 @@ -40,9 +40,19 @@
     2.4      }
     2.5      
     2.6      [_cond signal];
     2.7 -    
     2.8      [_cond unlock];
     2.9 -    
    2.10 +}
    2.11 +
    2.12 +- (void)prequeue:(id)object
    2.13 +{
    2.14 +    [_cond lock];
    2.15 +
    2.16 +    if (_queue) {
    2.17 +        [_queue addObject:object];
    2.18 +    }
    2.19 +
    2.20 +    [_cond signal];
    2.21 +    [_cond unlock];
    2.22  }
    2.23  
    2.24  - (id)timedDequeue:(time_t*)timeout