lib/demiurge.rb
# Send out all pending {Demiurge::Intention}s in the
# {Demiurge::Intention} queue. This will ordinarily happen at
# least once per tick in any case. Calling this method outside the
# Engine's Intention phase of a tick may cause unexpected results.
#
# @return [void]
# @since 0.0.1
Send out all pending {Demiurge::Intention}s in the
{Demiurge::Intention} queue. This will ordinarily happen at
least once per tick in any case. Calling this method outside the
Engine's Intention phase of a tick may cause unexpected results.
Send out all pending { Demiurge :: Intention } s in the { Demiurge :: Intention } queue . This will ordinarily happen at least once per tick in any case . Calling this method outside the Engine ' s Intention phase of a tick may cause unexpected results .
def flush_intentions
      state_backup = structured_state("copy" => true)
      infinite_loop_detector = 0
      until @queued_intentions.empty?
        infinite_loop_detector += 1
        if infinite_loop_detector > 20
          raise ::Demiurge::Errors::TooManyIntentionLoopsError.new("Over 20 batches of intentions were dispatched in the same call! Error and die!", "final_batch" => @queued_intentions.map { |i| i.class.to_s })
        end
        intentions = @queued_intentions
        @queued_intentions = []
        begin
          intentions.each do |a|
            if a.cancelled?
              admin_warning("Trying to apply a cancelled intention of type #{a.class}!", "inspect" => a.inspect)
            else
              a.try_apply
            end
          end
        rescue ::Demiurge::Errors::RetryableError
          admin_warning("Exception when updating! Throwing away speculative state!", "exception" => $_.jsonable)
          load_state_from_dump(state_backup)
        end
      end
      @state_items["admin"].state["ticks"] += 1
      nil
    end
def flush_intentions state_backup = structured_state ( "copy" => true ) infinite_loop_detector = 0 until @queued_intentions . empty? infinite_loop_detector += 1 if infinite_loop_detector > 20 raise :: Demiurge :: Errors :: TooManyIntentionLoopsError . new ( "Over 20 batches of intentions were dispatched in the same call! Error and die!" , "final_batch" => @queued_intentions . map { | i | i . class . to_s } ) end intentions = @queued_intentions @queued_intentions = [ ] begin intentions . each do | a | if a . cancelled? admin_warning ( "Trying to apply a cancelled intention of type #{a.class}!" , "inspect" => a . inspect ) else a . try_apply end end rescue :: Demiurge :: Errors :: RetryableError admin_warning ( "Exception when updating! Throwing away speculative state!" , "exception" => $_ . jsonable ) load_state_from_dump ( state_backup ) end end @state_items [ "admin" ] . state [ "ticks" ] += 1 nil end
Send out all pending {Demiurge::Intention}s in the
{Demiurge::Intention} queue.
Send out all pending { Demiurge :: Intention } s in the { Demiurge :: Intention } queue .
None
void
since
None