examples/internet/config.ru
# This method uses the experimental `Sync` method to create a reactor if required. If the code is already running in a reactor, it runs synchronously, otherwise it's effectively the same as `Async` and a blocking operation. This allow you to write efficient non-blocking code that works in both traditional web application servers, but gains additional scalability in `Async`-aware servers like Falcon.
# You can achieve a similar result by calling `Async{}.wait`, but this is less efficient as it will allocate a sub-task even thought it's not needed.
This method uses the experimental `Sync` method to create a reactor if required. If the code is already running in a reactor, it runs synchronously, otherwise it's effectively the same as `Async` and a blocking operation. This allow you to write efficient non-blocking code that works in both traditional web application servers, but gains additional scalability in `Async`-aware servers like Falcon.
You can achieve a similar result by calling `Async{}.wait`, but this is less efficient as it will allocate a sub-task even thought it's not needed.
This method uses the experimental ` Sync ` method to create a reactor if required . If the code is already running in a reactor it runs synchronously otherwise it ' s effectively the same as ` Async ` and a blocking operation . This allow you to write efficient non - blocking code that works in both traditional web application servers but gains additional scalability in ` Async ` - aware servers like Falcon . You can achieve a similar result by calling ` Async {} . wait ` but this is less efficient as it will allocate a sub - task even thought it ' s not needed .
def sync(close: !Async::Task.current?)
		Sync do
			response = @internet.get("https://google.com/search?q=async+ruby")
			puts response.inspect
		ensure
			response&.finish
		end
	end
def sync ( close : ! Async :: Task . current? ) Sync do response = @internet . get ( "https://google.com/search?q=async+ruby" ) puts response . inspect ensure response &. finish end end
This method uses the experimental `Sync` method to create a reactor if required.
This method uses the experimental ` Sync ` method to create a reactor if required .
close
<not_specific>
current?
<not_specific>