Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved set_timeout to Base, as non-entities can use it as well.

  • Loading branch information...
commit 8aa33cdee0b6adb9aa0db76043fd3dc761eef21e 1 parent 970bd37
Cyrus Hall authored
Showing with 18 additions and 9 deletions.
  1. +18 −1 lib/gosim.rb
  2. +0 −8 lib/gosim/simulation.rb
View
19 lib/gosim.rb
@@ -16,7 +16,17 @@
end
module GoSim
- MAX_INT = 2**31
+ #MAX_INT = 2**31
+
+ module Base
+
+ end
+
+ # We need a predefinition for Base - defined gosim/simulation
+ class Entity
+ class SimTimeout < Entity
+ end
+ end
module Base
# TODO: Figure out what we want to do for a logging framework.
@@ -40,6 +50,13 @@ def quiet
def verbose
@@log.level = Logger::DEBUG
end
+
+ # Set a block of code to run after wait_time units of time. If the
+ # is_periodic flag is set it will continue to run every wait_time units.
+ def set_timeout(wait_time, is_periodic = false, data = nil, method = nil, &block)
+ SimTimeout.new(wait_time, is_periodic, data, method || block)
+ end
+
end
end
View
8 lib/gosim/simulation.rb
@@ -36,12 +36,6 @@ def die
@sim.unregister_entity(@sid)
end
- # Set a block of code to run after wait_time units of time. If the
- # is_periodic flag is set it will continue to run every wait_time units.
- def set_timeout(wait_time, is_periodic = false, data = nil, method = nil, &block)
- SimTimeout.new(wait_time, is_periodic, data, method || block)
- end
-
# Override the default inspect so entities with lots of state don't fill
# the screen during debug. Implement your own inspect method to print
# useful information about your Entity.
@@ -57,8 +51,6 @@ def handle_sim_timeout(t)
end
class SimTimeout < Entity
- include Base
-
attr_reader :time, :is_periodic, :active
def initialize(time, is_periodic, data, block)
Please sign in to comment.
Something went wrong with that request. Please try again.