Skip to content

jvoegele/wait_for_it

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WaitForIt

Various ways to wait for things to happen.

Since most Elixir systems are highly concurrent, there must be a way to coordinate and synchronize the processes in the system. While the language provides features (such as Process.sleep/1 and receive/after) that can be used to implement such synchronization, they are inconvenient to use for this purpose. WaitForIt builds on top of these language features to provide convenient and easy-to-use facilities for synchronizing concurrent activities. While this is likely most useful for test code in which tests must wait for concurrent or asynchronous activities to complete, it is also useful in any scenario where concurrent processes must coordinate their activity. Examples include asynchronous event handling, producer-consumer processes, and time-based activity.

There are three distinct forms of waiting provided:

  1. The wait macro waits until a given expression evaluates to a truthy value.
  2. The case_wait macro waits until a given expression evaluates to a value that matches any one of the given case clauses (looks like an Elixir case expression).
  3. The cond_wait macro waits until any one of the given expressions evaluates to a truthy value (looks like an Elixir cond expression).

See the API reference for full documentation.

Installation

wait_for_it can be installed from Hex by adding wait_for_it to your list of dependencies in mix.exs:

def deps do
  [
    {:wait_for_it, "~> 1.1"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/wait_for_it.

Sponsored by Ropig http://ropig.com

About

Elixir library for waiting for things to happen

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages