libs-base/Source/NSBackgroundActivityScheduler.m

139 lines
3 KiB
Mathematica
Raw Normal View History

2019-10-26 11:45:19 +00:00
/* Implementation of class NSBackgroundActivityScheduler
Copyright (C) 2019 Free Software Foundation, Inc.
By: Gregory John Casamento <greg.casamento@gmail.com>
Date: Fri Oct 25 00:52:54 EDT 2019
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#include <Foundation/NSBackgroundActivityScheduler.h>
@implementation NSBackgroundActivityScheduler
2019-10-26 12:11:59 +00:00
- (instancetype) initWithIdentifier: (NSString *)identifier
{
self = [super init];
if(self != nil)
{
_identifier = identifier;
_qualityOfService = NSQualityOfServiceDefault;
_repeats = NO;
_interval = 0;
_tolerance = 0;
_shouldDefer = NO;
_timer = nil;
}
return self;
2019-10-26 12:11:59 +00:00
}
- (NSString *) identifier
{
return _identifier;
2019-10-26 12:11:59 +00:00
}
- (void) setIdentifier: (NSString *)identifier
{
ASSIGNCOPY(_identifier, identifier);
2019-10-26 12:11:59 +00:00
}
- (NSQualityOfService) qualityOfService
{
return _qualityOfService;
2019-10-26 12:11:59 +00:00
}
- (void) setQualityOfService: (NSQualityOfService)qualityOfService
{
_qualityOfService = qualityOfService;
2019-10-26 12:11:59 +00:00
}
- (BOOL) repeats
{
return _repeats;
2019-10-26 12:11:59 +00:00
}
- (void) setRepeats: (BOOL)flag
{
_repeats = flag;
2019-10-26 12:11:59 +00:00
}
- (NSTimeInterval) interval
{
return _interval;
2019-10-26 12:11:59 +00:00
}
- (void) setInterval: (NSTimeInterval)interval
{
_interval = interval;
2019-10-26 12:11:59 +00:00
}
- (NSTimeInterval) tolerance
{
return _tolerance;
2019-10-26 12:11:59 +00:00
}
- (void) setTolerance: (NSTimeInterval)tolerance
2019-10-26 12:11:59 +00:00
{
_tolerance = tolerance;
2019-10-26 12:11:59 +00:00
}
- (BOOL) shouldDefer
{
return _shouldDefer;
2019-10-26 12:11:59 +00:00
}
- (void) setShouldDefer: (BOOL)flag
{
_shouldDefer = flag;
2019-10-26 12:11:59 +00:00
}
- (void) scheduleWithBlock: (GSScheduledBlock)block
{
NSProcessInfo *pinfo = [NSProcessInfo processInfo];
id token = nil;
NSActivityOptions opts = 0;
switch(qualityOfService)
{
case NSQualityOfServiceUserInteractive:
opts = NSActivityUserInitiated | NSActivityIdleDisplaySleepDisabled;
break;
case NSQualityOfServiceUserInitiated:
opts = NSActivityUserInitiated;
break;
case NSQualityOfServiceUtility:
opts = NSActivityUserInitiated | NSActivityIdleDisplaySleepDisabled;
break;
case NSQualityOfServiceBackground:
opts = NSActivityBackground;
break;
case NSQualityOfServiceDefault:
opts = NSActivityLatencyCritical;
break;
}
token = [pinfo beginActivityWithOptions:
2019-10-26 12:11:59 +00:00
}
- (void) invalidate
{
}
2019-10-26 11:45:19 +00:00
@end