2017 © Pedro Peláez
 

library asio-utilities

Utilities to make working with async functions easier

image

hhvm/asio-utilities

Utilities to make working with async functions easier

  • Thursday, December 10, 2015
  • by fredemmott
  • Repository
  • 12 Watchers
  • 5 Stars
  • 1,258 Installations
  • Hack
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

ASIO Utilities

Obsolete In HHVM 3.11+

These functions have been merged into HHVM, and we expected them to be included from 3.11.0 onwards., (*1)

Installation

  • add hhvm/asio-utilities to your composer.json

ResultOrExceptionWrapper

When awaiting multiple handles, it can be useful to isolate exceptions from each; ResultOrExceptionWrapper provides this:, (*2)

// HH\Asio\wrap(T): Awaitable<ResultOrExceptionWrapper<T>>
$w = await wrap(some_async_function_that_may_throw());
if ($w->isSucceeded()) {
  $result = $w->getResult();
  ...
} else {
  $exception = $w->getException();
  ...
}

Mapping and Filtering Functions

HHVM 3.6 and above include HH\Asio\v() and HH\Asio\m() to make it easy to wait on multiple wait handles; it's fairly common to want to combine this with another option, such as mapping or filtering with an async function., (*3)

These functions are named according to their attributes:, (*4)

First, how they take and return arguments according to types: * v - Vector * m - Map, (*5)

Then, either one or two letters to indicate the operation: * f - filter * fk - filter with key * m - map * mk - map with keys, (*6)

Finally, there is optionally a trailing 'w' to indicate that you want a result or exception wrapper. For 'fw' functions, the behavior is that:, (*7)

  • if the filter function returns true, the wrapped element is returned
  • if the filter function returns false, the element is omitted
  • if the filter function throws an exception, the wrapped exception is returned

This is also available without a filter or mapping operation - vw() and mw()., (*8)

Function List

All functions are in the HH\Asio namespace; v() and m() are built in to HHVM 3.6 and newer., (*9)

Name Returns Mapped Filtered with key Wrapped Callback
v() Vector<T> :x: :x: :x: :x:
vm() Vector<Tr> :white_check_mark: :x: :x: :x: (Tv): Awaitable<Tr>
vmk() Vector<Tr> :white_check_mark: :x: :white_check_mark: :x: (Tk, Tv): Awaitable<Tr>
vf() Vector<Tv> :x: :white_check_mark: :x: :x: (Tv): Awaitable<bool>
vfk() Vector<Tv> :x: :white_check_mark: :white_check_mark: :x: (Tk, Tv): Awaitable<bool>
vw() Vector<ResultOrExceptionWrapper<T>> :x: :x: :x: :white_check_mark:
vmw() Vector<ResultOrExceptionWrapper<Tr>> :white_check_mark: :x: :x: :white_check_mark: (Tv): Awaitable<Tr>
vmkw() Vector<ResultOrExceptionWrapper<Tr>> :white_check_mark: :x: :white_check_mark: :white_check_mark: (Tk, Tv): Awaitable<Tr>
vfw() Vector<ResultOrExceptionWrapper<Tv>> :x: :white_check_mark: :x: :white_check_mark: (Tv): Awaitable<bool>
vfkw() Vector<ResultOrExceptionWrapper<Tv>> :x: :white_check_mark: :white_check_mark: :white_check_mark: (Tk, Tv): Awaitable<bool>
m() Map<Tk, Tv> :x: :x: :x: :x:
mm() Map<Tk, Tr> :white_check_mark: :x: :x: :x: (Tv): Awaitable<Tr>
mmk() Map<Tk, Tr> :white_check_mark: :x: :white_check_mark: :x: (Tk, Tv): Awaitable<Tr>
mf() Map<Tk, Tv> :x: :white_check_mark: :x: :x: (Tv): Awaitable<bool>
mfk() Map<Tk, Tv> :x: :white_check_mark: :white_check_mark: :x: (Tk, Tv): Awaitable<bool>
mw() Map<Tk, ResultOrExceptionWrapper<T>> :x: :x: :x: :white_check_mark:
mmw() Map<Tk, ResultOrExceptionWrapper<Tr>> :white_check_mark: :x: :x: :white_check_mark: (Tv): Awaitable<Tr>
mmkw() Map<Tk, ResultOrExceptionWrapper<Tr>> :white_check_mark: :x: :white_check_mark: :white_check_mark: (Tk, Tv): Awaitable<Tr>
mfw() Map<Tk, ResultOrExceptionWrapper<Tv>> :x: :white_check_mark: :x: :white_check_mark: (Tv): Awaitable<bool>
mfkw() Map<Tk, ResultOrExceptionWrapper<Tv>> :x: :white_check_mark: :white_check_mark: :white_check_mark: (Tk, Tv): Awaitable<bool>

The Versions

10/12 2015

dev-master

9999999-dev https://github.com/hhvm/asio-utilities

Utilities to make working with async functions easier

  Sources   Download

BSD-3-Clause

The Requires

  • hhvm ~3.11.0 | ~3.12.0

 

facebook hack hhvm async asio

10/12 2015

v2.4

2.4.0.0 https://github.com/hhvm/asio-utilities

Utilities to make working with async functions easier

  Sources   Download

BSD-3-Clause

The Requires

  • hhvm ~3.11.0 | ~3.12.0

 

facebook hack hhvm async asio

15/10 2015

v2.3

2.3.0.0 https://github.com/hhvm/asio-utilities

Utilities to make working with async functions easier

  Sources   Download

BSD-3-Clause

The Requires

  • hhvm ~3.8.0 | ~3.9.0 | ~3.10.0 | 3.11-dev

 

facebook hack hhvm async asio

18/08 2015

v2.2

2.2.0.0 https://github.com/hhvm/asio-utilities

Utilities to make working with async functions easier

  Sources   Download

BSD-3-Clause

The Requires

  • hhvm ~3.8.0 | ~3.9.0 | 3.10-dev

 

facebook hack hhvm async asio

13/08 2015

v2.1

2.1.0.0 https://github.com/hhvm/asio-utilities

Utilities to make working with async functions easier

  Sources   Download

BSD-3-Clause

The Requires

  • hhvm >= 3.8 <= 3.9

 

facebook hack hhvm async asio

19/07 2015

v2.0

2.0.0.0 https://github.com/hhvm/asio-utilities

Utilities to make working with async functions easier

  Sources   Download

BSD-3-Clause

The Requires

  • hhvm ~3.8.0

 

facebook hack hhvm async asio

19/07 2015

v1.1

1.1.0.0 https://github.com/hhvm/asio-utilities

Utilities to make working with async functions easier

  Sources   Download

BSD-3-Clause

The Requires

  • hhvm >=3.6,<3.8

 

facebook hack hhvm async asio

21/05 2015

v1.0

1.0.0.0 https://github.com/hhvm/asio-utilities

Utilities to make working with async functions easier

  Sources   Download

BSD-3-Clause

facebook hack hhvm async asio

21/02 2015

v0.1

0.1.0.0 https://github.com/hhvm/asio-utilities

Utilties to make working with async functions easier

  Sources   Download

BSD-3-Clause

facebook hack hhvm async asio