Changeset 226
- Timestamp:
- 06/11/05 18:39:00 (3 years ago)
- Location:
- trunk/lib/fm
- Files:
-
- 2 modified
-
entity.rb (modified) (3 diffs)
-
gameobject.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/fm/entity.rb
r213 r226 105 105 106 106 107 ######### 108 protected 109 ######### 110 111 ### Fallback event handler. The default implementation of this method 112 ### just raises an UnhandledEventError, so deriviatives will probably 113 ### want to override it. 114 def handleAnyEvent( event ) 115 raise FaerieMUD::UnhandledEventError, 116 "No handler defined for #{event.class.name}s" 117 end 118 119 107 120 ### Get a handler as a callable object for the given +event+. 108 121 def getHandlerForEvent( event ) … … 140 153 141 154 142 ### Fallback event handler. The default implementation of this method143 ### just raises an UnhandledEventError, so deriviatives will probably144 ### want to override it.145 def handleAnyEvent( event )146 raise FaerieMUD::UnhandledEventError,147 "No handler defined for #{event.class.name}s"148 end149 150 151 155 ### Callback invoked whenever a singleton method is added to the 152 156 ### receiver. Clears the event handler lookup cache if the method being … … 161 165 alias_method :singleton_method_undefined, :singleton_method_added 162 166 163 164 #############################################################165 ### L O C K I N G M E T H O D S166 #############################################################167 168 ### Obtain a shared lock on the receiver for the duration of the169 ### block. The mutex object is passed as argument.170 def readlocked171 return unless block_given?172 @mutex.synchronize( Sync::SH ) {173 yield( @mutex )174 }175 end176 177 178 #########179 protected180 #########181 182 ### Obtain an exclusive lock on the receiver for the durection of the183 ### block. The mutex object is passed as argument.184 def writelocked185 return unless block_given?186 @mutex.synchronize( Sync::EX ) {187 yield( @mutex )188 }189 end190 191 167 end # class FaerieMUD::Entity 192 168 -
trunk/lib/fm/gameobject.rb
r215 r226 198 198 199 199 200 201 200 ### Return the number of contribution points for the given +author+ (a 202 201 ### String) the object is worth. 203 202 def contribution( author ) 204 203 self.class.authors[ author ] 204 end 205 206 207 ### Obtain a shared lock on the receiver for the duration of the 208 ### block. The mutex object is passed as argument. 209 def readlocked 210 return unless block_given? 211 @mutex.synchronize( Sync::SH ) { 212 yield( @mutex ) 213 } 205 214 end 206 215 … … 224 233 protected 225 234 ######### 235 236 ### Obtain an exclusive lock on the receiver for the durection of the 237 ### block. The mutex object is passed as argument. 238 def writelocked 239 return unless block_given? 240 @mutex.synchronize( Sync::EX ) { 241 yield( @mutex ) 242 } 243 end 244 226 245 227 246 ### Return an HTML fragment for the header part of the given object.
