Skip to content
This repository was archived by the owner on Aug 6, 2024. It is now read-only.

Commit bdaf3be

Browse files
committed
Adds OneShotTimer and OneShotDispatch Timer
Refactors ExecutionClosures to RepeatedExecutionClosure and OneShotExecutionClosure
1 parent 7450d48 commit bdaf3be

8 files changed

Lines changed: 473 additions & 25 deletions

File tree

Chronos.xcodeproj/project.pbxproj

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
054C97901D5518F200C481BD /* OneShotDispatchTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C978F1D5518F200C481BD /* OneShotDispatchTimer.swift */; };
11+
054C97911D551DBF00C481BD /* OneShotDispatchTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C978F1D5518F200C481BD /* OneShotDispatchTimer.swift */; };
12+
054C97921D551DC000C481BD /* OneShotDispatchTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C978F1D5518F200C481BD /* OneShotDispatchTimer.swift */; };
13+
054C97961D551FEA00C481BD /* OneShotTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C97951D551FEA00C481BD /* OneShotTimer.swift */; };
14+
054C97971D55201F00C481BD /* OneShotTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C97951D551FEA00C481BD /* OneShotTimer.swift */; };
15+
054C97981D55201F00C481BD /* OneShotTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C97951D551FEA00C481BD /* OneShotTimer.swift */; };
16+
054C97991D55219000C481BD /* OneShotTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C97951D551FEA00C481BD /* OneShotTimer.swift */; };
17+
054C979A1D55219100C481BD /* OneShotTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C97951D551FEA00C481BD /* OneShotTimer.swift */; };
18+
054C979B1D55219200C481BD /* OneShotTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C97951D551FEA00C481BD /* OneShotTimer.swift */; };
19+
054C979C1D5521E800C481BD /* OneShotTimerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C97931D551F2F00C481BD /* OneShotTimerTests.swift */; };
20+
054C979D1D5521EE00C481BD /* OneShotTimerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C97931D551F2F00C481BD /* OneShotTimerTests.swift */; };
21+
054C979E1D5521EF00C481BD /* OneShotTimerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C97931D551F2F00C481BD /* OneShotTimerTests.swift */; };
22+
054C979F1D55220B00C481BD /* OneShotDispatchTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C978F1D5518F200C481BD /* OneShotDispatchTimer.swift */; };
23+
054C97A01D55220C00C481BD /* OneShotDispatchTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C978F1D5518F200C481BD /* OneShotDispatchTimer.swift */; };
24+
054C97A11D55220C00C481BD /* OneShotDispatchTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054C978F1D5518F200C481BD /* OneShotDispatchTimer.swift */; };
1025
6422C4A61AD38BBC00D480E8 /* Timer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6422C4A51AD38BBC00D480E8 /* Timer.swift */; };
1126
6422C4A71AD38C6F00D480E8 /* Timer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6422C4A51AD38BBC00D480E8 /* Timer.swift */; };
1227
6422C4A81AD38C6F00D480E8 /* Timer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6422C4A51AD38BBC00D480E8 /* Timer.swift */; };
@@ -101,6 +116,9 @@
101116
/* End PBXCopyFilesBuildPhase section */
102117

103118
/* Begin PBXFileReference section */
119+
054C978F1D5518F200C481BD /* OneShotDispatchTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OneShotDispatchTimer.swift; sourceTree = "<group>"; };
120+
054C97931D551F2F00C481BD /* OneShotTimerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OneShotTimerTests.swift; sourceTree = "<group>"; };
121+
054C97951D551FEA00C481BD /* OneShotTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OneShotTimer.swift; sourceTree = "<group>"; };
104122
6422C4A51AD38BBC00D480E8 /* Timer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Timer.swift; sourceTree = "<group>"; };
105123
644FA4141ADE19560007B808 /* TimerInternal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimerInternal.swift; sourceTree = "<group>"; };
106124
644FA4161ADE19760007B808 /* VariableTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VariableTimer.swift; sourceTree = "<group>"; };
@@ -199,6 +217,8 @@
199217
64FFA21A1ADE1932006E36D3 /* RepeatingTimer.swift */,
200218
64B3CE381ACDDA7E00145E36 /* DispatchTimer.swift */,
201219
644FA4161ADE19760007B808 /* VariableTimer.swift */,
220+
054C97951D551FEA00C481BD /* OneShotTimer.swift */,
221+
054C978F1D5518F200C481BD /* OneShotDispatchTimer.swift */,
202222
64B3CE1F1ACDDA2800145E36 /* Supporting Files */,
203223
);
204224
path = Chronos;
@@ -217,6 +237,7 @@
217237
children = (
218238
644FA4221ADE19A50007B808 /* DispatchTimerTests.swift */,
219239
64502B951ADE19C50008443B /* VariableTimerTests.swift */,
240+
054C97931D551F2F00C481BD /* OneShotTimerTests.swift */,
220241
64B3CE2C1ACDDA2800145E36 /* Supporting Files */,
221242
);
222243
path = ChronosTests;
@@ -473,10 +494,12 @@
473494
isa = PBXSourcesBuildPhase;
474495
buildActionMask = 2147483647;
475496
files = (
497+
054C97901D5518F200C481BD /* OneShotDispatchTimer.swift in Sources */,
476498
644FA4151ADE19560007B808 /* TimerInternal.swift in Sources */,
477499
64B3CE391ACDDA7E00145E36 /* DispatchTimer.swift in Sources */,
478500
644FA4171ADE19760007B808 /* VariableTimer.swift in Sources */,
479501
64FFA21B1ADE1932006E36D3 /* RepeatingTimer.swift in Sources */,
502+
054C97961D551FEA00C481BD /* OneShotTimer.swift in Sources */,
480503
6422C4A61AD38BBC00D480E8 /* Timer.swift in Sources */,
481504
);
482505
runOnlyForDeploymentPostprocessing = 0;
@@ -491,6 +514,9 @@
491514
644FA4201ADE19840007B808 /* RepeatingTimer.swift in Sources */,
492515
644FA4191ADE197C0007B808 /* VariableTimer.swift in Sources */,
493516
644FA41E1ADE19810007B808 /* TimerInternal.swift in Sources */,
517+
054C97991D55219000C481BD /* OneShotTimer.swift in Sources */,
518+
054C979C1D5521E800C481BD /* OneShotTimerTests.swift in Sources */,
519+
054C979F1D55220B00C481BD /* OneShotDispatchTimer.swift in Sources */,
494520
64B8678C1ACFCE070020EDDA /* DispatchTimer.swift in Sources */,
495521
);
496522
runOnlyForDeploymentPostprocessing = 0;
@@ -499,11 +525,13 @@
499525
isa = PBXSourcesBuildPhase;
500526
buildActionMask = 2147483647;
501527
files = (
528+
054C97921D551DC000C481BD /* OneShotDispatchTimer.swift in Sources */,
502529
64C884261C026886005DB548 /* TimerInternal.swift in Sources */,
503530
64C884271C026886005DB548 /* Timer.swift in Sources */,
504531
64C884281C026886005DB548 /* RepeatingTimer.swift in Sources */,
505532
64C884291C026886005DB548 /* DispatchTimer.swift in Sources */,
506533
64C8842A1C026886005DB548 /* VariableTimer.swift in Sources */,
534+
054C97981D55201F00C481BD /* OneShotTimer.swift in Sources */,
507535
);
508536
runOnlyForDeploymentPostprocessing = 0;
509537
};
@@ -517,6 +545,9 @@
517545
64C8842D1C0268A1005DB548 /* Timer.swift in Sources */,
518546
64C8842E1C0268A1005DB548 /* RepeatingTimer.swift in Sources */,
519547
64C8842F1C0268A1005DB548 /* DispatchTimer.swift in Sources */,
548+
054C979B1D55219200C481BD /* OneShotTimer.swift in Sources */,
549+
054C979E1D5521EF00C481BD /* OneShotTimerTests.swift in Sources */,
550+
054C97A11D55220C00C481BD /* OneShotDispatchTimer.swift in Sources */,
520551
64C884301C0268A1005DB548 /* VariableTimer.swift in Sources */,
521552
);
522553
runOnlyForDeploymentPostprocessing = 0;
@@ -525,11 +556,13 @@
525556
isa = PBXSourcesBuildPhase;
526557
buildActionMask = 2147483647;
527558
files = (
559+
054C97911D551DBF00C481BD /* OneShotDispatchTimer.swift in Sources */,
528560
644FA41B1ADE197F0007B808 /* TimerInternal.swift in Sources */,
529561
648578B41AD0F49A005F4297 /* DispatchTimer.swift in Sources */,
530562
644FA4181ADE197B0007B808 /* VariableTimer.swift in Sources */,
531563
6422C4A71AD38C6F00D480E8 /* Timer.swift in Sources */,
532564
644FA41F1ADE19840007B808 /* RepeatingTimer.swift in Sources */,
565+
054C97971D55201F00C481BD /* OneShotTimer.swift in Sources */,
533566
);
534567
runOnlyForDeploymentPostprocessing = 0;
535568
};
@@ -543,6 +576,9 @@
543576
644FA4211ADE19850007B808 /* RepeatingTimer.swift in Sources */,
544577
644FA41A1ADE197C0007B808 /* VariableTimer.swift in Sources */,
545578
644FA41C1ADE19800007B808 /* TimerInternal.swift in Sources */,
579+
054C979A1D55219100C481BD /* OneShotTimer.swift in Sources */,
580+
054C979D1D5521EE00C481BD /* OneShotTimerTests.swift in Sources */,
581+
054C97A01D55220C00C481BD /* OneShotDispatchTimer.swift in Sources */,
546582
64B0D0F71AD0E58A0020EFE1 /* DispatchTimer.swift in Sources */,
547583
);
548584
runOnlyForDeploymentPostprocessing = 0;
@@ -722,10 +758,7 @@
722758
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
723759
CODE_SIGN_IDENTITY = "iPhone Developer";
724760
DEFINES_MODULE = YES;
725-
FRAMEWORK_SEARCH_PATHS = (
726-
"$(SDKROOT)/Developer/Library/Frameworks",
727-
"$(inherited)",
728-
);
761+
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
729762
GCC_PREPROCESSOR_DEFINITIONS = (
730763
"DEBUG=1",
731764
"$(inherited)",
@@ -744,10 +777,7 @@
744777
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
745778
CODE_SIGN_IDENTITY = "iPhone Developer";
746779
DEFINES_MODULE = YES;
747-
FRAMEWORK_SEARCH_PATHS = (
748-
"$(SDKROOT)/Developer/Library/Frameworks",
749-
"$(inherited)",
750-
);
780+
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
751781
INFOPLIST_FILE = ChronosTests/Info.plist;
752782
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
753783
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@@ -888,7 +918,7 @@
888918
DD9ED4691AD0B36A0068D45E /* Debug */ = {
889919
isa = XCBuildConfiguration;
890920
buildSettings = {
891-
CODE_SIGN_IDENTITY = "Mac Developer";
921+
CODE_SIGN_IDENTITY = "";
892922
COMBINE_HIDPI_IMAGES = YES;
893923
FRAMEWORK_SEARCH_PATHS = (
894924
"$(DEVELOPER_FRAMEWORKS_DIR)",
@@ -910,7 +940,7 @@
910940
DD9ED46A1AD0B36A0068D45E /* Release */ = {
911941
isa = XCBuildConfiguration;
912942
buildSettings = {
913-
CODE_SIGN_IDENTITY = "Mac Developer";
943+
CODE_SIGN_IDENTITY = "";
914944
COMBINE_HIDPI_IMAGES = YES;
915945
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
916946
FRAMEWORK_SEARCH_PATHS = (

Chronos/DispatchTimer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class DispatchTimer : NSObject, RepeatingTimer {
7171
/**
7272
The timer's execution closure.
7373
*/
74-
public let closure: ExecutionClosure!
74+
public let closure: RepeatedExecutionClosure!
7575

7676
/**
7777
The number of times the execution closure has been executed.
@@ -108,7 +108,7 @@ public class DispatchTimer : NSObject, RepeatingTimer {
108108

109109
- returns: A newly created DispatchTimer object.
110110
*/
111-
convenience public init(interval: Double, closure: ExecutionClosure) {
111+
convenience public init(interval: Double, closure: RepeatedExecutionClosure) {
112112
let name = "\(queuePrefix).\(NSUUID().UUIDString)"
113113
let queue = dispatch_queue_create((name as NSString).UTF8String, DISPATCH_QUEUE_SERIAL)
114114
self.init(interval: interval, closure: closure, queue: queue)
@@ -123,7 +123,7 @@ public class DispatchTimer : NSObject, RepeatingTimer {
123123

124124
- returns: A newly created DispatchTimer object.
125125
*/
126-
convenience public init(interval: Double, closure: ExecutionClosure, queue: dispatch_queue_t) {
126+
convenience public init(interval: Double, closure: RepeatedExecutionClosure, queue: dispatch_queue_t) {
127127
self.init(interval: interval, closure: closure, queue: queue, failureClosure: nil)
128128
}
129129

@@ -137,7 +137,7 @@ public class DispatchTimer : NSObject, RepeatingTimer {
137137

138138
- returns: A newly created DispatchTimer object.
139139
*/
140-
public init(interval: Double, closure: ExecutionClosure, queue: dispatch_queue_t, failureClosure: FailureClosure) {
140+
public init(interval: Double, closure: RepeatedExecutionClosure, queue: dispatch_queue_t, failureClosure: FailureClosure) {
141141
if let timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue) {
142142
self.timer = timer
143143
self.valid = State.valid

0 commit comments

Comments
 (0)