Files
Yukihiro "Matz" Matsumoto 2a124a704f mruby-task: add comprehensive examples demonstrating task features
added six new examples:
- simple.rb: basic task creation and execution
- priority.rb: priority-based scheduling
- suspend_resume.rb: manual task control
- inspection.rb: task status and inspection methods
- statistics.rb: scheduler monitoring with Task.stat
- producer_consumer.rb: task coordination pattern

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-10 17:44:31 +09:00

28 lines
475 B
Ruby

# Simple Task Example
# Basic usage of mruby-task
puts "=== Simple Task Demo ==="
puts
# Create a simple task
Task.new(name: "hello") do
3.times do |i|
puts "Hello from task, iteration #{i}"
sleep 0.5
end
end
# Create another task
Task.new(name: "world") do
3.times do |i|
puts "World from task, iteration #{i}"
sleep 0.7
end
end
# Run the scheduler - blocks until all tasks complete
puts "Starting tasks..."
Task.run
puts "All tasks completed!"