Add async API

For longer lines and larger patterns, an async API is needed.