OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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

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

Definition at line 86 of file StdSchedulerMac.mm.

References procAdditions.

Referenced by StdScheduler::Changed().

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

Here is the caller graph for this function:

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

Definition at line 105 of file StdSchedulerMac.mm.

References StdSchedulerProc::IsNotify(), procAdditions, SCHAddition::registerAt:, and StdSchedulerProc::TimerInterval().

Referenced by StdScheduler::Added().

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:88
virtual bool IsNotify()
Definition: StdScheduler.h:87

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) changed: (SCHAddition*)  addition

Definition at line 132 of file StdSchedulerMac.mm.

References SCHAddition::registerAt:, and SCHAddition::unregisterFrom:.

Referenced by SCHAddition::changed.

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

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) initWithScheduler: (StdScheduler*)  scheduler

Definition at line 75 of file StdSchedulerMac.mm.

References procAdditions, and scheduler.

75  :(StdScheduler*) scheduler
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
- (BOOL) removeAdditionForProc: (StdSchedulerProc*)  proc

Definition at line 91 of file StdSchedulerMac.mm.

References procAdditions, and SCHAddition::unregisterFrom:.

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 }
void unregisterFrom:(SCHAdditions *_additions)

Here is the call graph for this function:

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

Definition at line 148 of file StdSchedulerMac.mm.

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

148  :(StdScheduler *)scheduler
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 }

Here is the caller graph for this function:

- (void) start

Definition at line 122 of file StdSchedulerMac.mm.

References procAdditions.

Referenced by StdScheduler::StartOnCurrentThread().

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 }

Here is the caller graph for this function:

Member Data Documentation

- (NSMutableDictionary*) procAdditions
protected

Property Documentation

- (__weak NSRunLoop*) runLoop
readatomicassign

Definition at line 65 of file StdSchedulerMac.mm.

Referenced by SCHNotify::registerAt:, and SCHTimer::registerAt:.

- (StdScheduler*) scheduler
readatomicassign

Definition at line 66 of file StdSchedulerMac.mm.

Referenced by initWithScheduler:.


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