Browse Source

Added Sync message queue timeout

IOSAD-21
Edouard Tisserant 5 years ago
parent
commit
91ec79fd0f
3 changed files with 28 additions and 6 deletions
  1. +1
    -3
      pEpObjCAdapter/PEPObjCAdapter.m
  2. +2
    -0
      pEpObjCAdapter/PEPQueue.h
  3. +25
    -3
      pEpObjCAdapter/PEPQueue.m

+ 1
- 3
pEpObjCAdapter/PEPObjCAdapter.m View File

@ -90,8 +90,7 @@ void *retrieve_next_sync_msg(void *unused_mamagement, time_t *timeout)
PEPQueue *q = [PEPObjCAdapter getSyncQueue];
// TODO : implement timeout
void* result = (void*)[[q dequeue] pointerValue];
void* result = (void*)[[q timedDequeue:timeout] pointerValue];
if ( syncDelegate && needs_fastpoll )
[syncDelegate fastPolling:false];
@ -100,7 +99,6 @@ void *retrieve_next_sync_msg(void *unused_mamagement, time_t *timeout)
}
///////////////////////////////////////////////////////////////////////////////
// DB and paths


+ 2
- 0
pEpObjCAdapter/PEPQueue.h View File

@ -12,6 +12,8 @@
- (void)enqueue:(id)object;
- (id)timedDequeue:(time_t*)timeout;
- (id)dequeue;
- (void)kill;


+ 25
- 3
pEpObjCAdapter/PEPQueue.m View File

@ -52,7 +52,7 @@
return res;
}
- (id)dequeue
- (id)timedDequeue:(time_t*)timeout
{
id tmp = nil;
@ -60,7 +60,23 @@
while ([self condwait])
{
[_cond wait];
if (*timeout == 0)
{
[_cond wait];
}
else
{
NSDate *end = [NSDate dateWithTimeIntervalSinceNow: *timeout];
[_cond waitUntilDate:end];
NSTimeInterval remaining = [end timeIntervalSinceNow];
if (remaining > 0)
*timeout = remaining;
else
*timeout = 0;
}
}
@synchronized(self) {
@ -76,6 +92,12 @@
return tmp;
}
- (id)dequeue
{
time_t zeroTimeout = 0;
return [self timedDequeue:&zeroTimeout];
}
- (void)kill
{
_queue = nil;
@ -94,4 +116,4 @@
self.cond = nil;
}
@end
@end

Loading…
Cancel
Save