OpenClonk
SCHAdditions Class Reference
Inheritance diagram for SCHAdditions:
[legend]
Collaboration diagram for SCHAdditions:
[legend]

Instance Methods

(id) - initWithScheduler:
 
(SCHAddition *) - additionForProc:
 
(SCHAddition *) - assignAdditionForProc:
 
(void) - changed:
 
(BOOL) - removeAdditionForProc:
 
(void) - start
 

Class Methods

(SCHAdditions *) + requestAdditionsForScheduler:
 

Protected Attributes

NSMutableDictionary * procAdditions
 

Properties

__weak NSRunLoop * runLoop
 
StdSchedulerscheduler
 

Detailed Description

Definition at line 54 of file StdSchedulerMac.mm.

Method Documentation

◆ additionForProc:

- (SCHAddition *) additionForProc: (StdSchedulerProc*)  proc

Definition at line 71 of file StdSchedulerMac.mm.

86  :(StdSchedulerProc*) proc
87 {
88  return [procAdditions objectForKey:[NSNumber valueWithPointer:proc]];
89 }

Referenced by StdScheduler::Changed().

Here is the caller graph for this function:

◆ assignAdditionForProc:

- (SCHAddition *) assignAdditionForProc: (StdSchedulerProc*)  proc

Definition at line 71 of file StdSchedulerMac.mm.

105  :(StdSchedulerProc*) proc
106 {
107  auto timerInterval = proc->TimerInterval();
108  auto addition =
109  timerInterval ? [[SCHTimer alloc] initWithProc:proc] :
110  proc->IsNotify() ? [[SCHNotify alloc] initWithProc:proc] :
111  nullptr;
112  if (addition)
113  {
114  [procAdditions setObject:addition forKey:[NSNumber valueWithPointer:proc]];
115  if (_runLoop)
116  [addition registerAt:self];
117  return addition;
118  } else
119  return nullptr;
120 }
virtual uint32_t TimerInterval()
Definition: StdScheduler.h:84
virtual bool IsNotify()
Definition: StdScheduler.h:83

Referenced by StdScheduler::Added().

Here is the caller graph for this function:

◆ changed:

- (void) changed: (SCHAddition*)  addition

Definition at line 71 of file StdSchedulerMac.mm.

132  :(SCHAddition*)addition
133 {
134  [addition unregisterFrom:self];
135  if (_runLoop)
136  [addition registerAt:self];
137 }
void unregisterFrom:(SCHAdditions *_additions)
void registerAt:(SCHAdditions *_additions)

◆ initWithScheduler:

- (id) initWithScheduler: (StdScheduler*)  scheduler

Definition at line 71 of file StdSchedulerMac.mm.

76 {
77  if (self = [super init])
78  {
79  _scheduler = scheduler;
80  procAdditions = [NSMutableDictionary new];
81  return self;
82  } else
83  return nil;
84 }
StdScheduler * scheduler
NSMutableDictionary * procAdditions

◆ removeAdditionForProc:

- (BOOL) removeAdditionForProc: (StdSchedulerProc*)  proc

Definition at line 71 of file StdSchedulerMac.mm.

91  :(StdSchedulerProc*) proc
92 {
93  auto key = [NSNumber valueWithPointer:proc];
94  SCHAddition* x = [procAdditions objectForKey:key];
95  if (x)
96  {
97  [x unregisterFrom:self];
98  [procAdditions removeObjectForKey:key];
99  return YES;
100  }
101  else
102  return NO;
103 }

◆ requestAdditionsForScheduler:

+ (SCHAdditions *) requestAdditionsForScheduler: (StdScheduler*)  scheduler

Definition at line 71 of file StdSchedulerMac.mm.

149 {
150  static dispatch_once_t onceToken;
151  dispatch_once(&onceToken,
152  ^{ additionsDictionary = [NSMutableDictionary new]; });
153  auto key = [NSNumber valueWithPointer:scheduler];
154  @synchronized (additionsDictionary)
155  {
156  SCHAdditions* additions = [additionsDictionary objectForKey:key];
157  if (!additions)
158  {
159  additions = [[SCHAdditions alloc] initWithScheduler:scheduler];
160  [additionsDictionary setObject:additions forKey:key];
161  }
162  return additions;
163  }
164 }

Referenced by StdScheduler::Added(), StdScheduler::Changed(), StdScheduler::Removing(), and StdScheduler::StartOnCurrentThread().

Here is the caller graph for this function:

◆ start

- (void) start

Definition at line 71 of file StdSchedulerMac.mm.

123 {
124  auto current = [NSRunLoop currentRunLoop];
125  if (current != [NSRunLoop mainRunLoop])
126  return; // oh well
127  _runLoop = current;
128  [procAdditions enumerateKeysAndObjectsUsingBlock:
129  ^void (id key, SCHAddition* obj, BOOL* stop) { [obj registerAt:self]; }];
130 }

Referenced by StdScheduler::StartOnCurrentThread().

Here is the caller graph for this function:

Member Data Documentation

◆ procAdditions

- (NSMutableDictionary*) procAdditions
protected

Definition at line 56 of file StdSchedulerMac.mm.

Property Documentation

◆ runLoop

- (__weak NSRunLoop*) runLoop
readatomicassign

Definition at line 65 of file StdSchedulerMac.mm.

◆ scheduler

- (StdScheduler*) scheduler
readatomicassign

Definition at line 66 of file StdSchedulerMac.mm.


The documentation for this class was generated from the following file: