Skip to content

Commit

Permalink
Refactor Crystal::Scheduler#fatal_resume_error for win32
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Jul 25, 2019
1 parent 7a1215d commit d388a7d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/crystal/scheduler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,23 @@ class Crystal::Scheduler
end

private def fatal_resume_error(fiber, message)
LibC.dprintf 2, "\nFATAL: #{message}: #{fiber}\n"
caller.each { |line| LibC.dprintf(2, " from #{line}\n") }
print_error "\nFATAL: #{message}: #{fiber}\n"
{% unless flag?(:win32) %}
# FIXME: Enable when caller is supported on win32
caller.each { |line| print_error " from #{line}\n" }
{% end %}

exit 1
end

private def print_error(message)
{% if flag?(:unix) %}
LibC.dprintf 2, message
{% elsif flag?(:win32) %}
LibC._write 2, message, message.bytesize
{% end %}
end

protected def reschedule : Nil
if runnable = @runnables.shift?
runnable.resume
Expand Down

0 comments on commit d388a7d

Please sign in to comment.