Skip to content

Releases: icicleio/icicle

v0.8.0

15 Aug 18:26
Compare
Choose a tag to compare

New Features

  • The default event loop can be swapped during execution. Normally this is not recommended and will break a program, but it can be useful in certain circumstances (forking, threading).
  • Added the function Icicle\Loop\with() that accepts a function that is run in a separate loop from the default event loop (a specific loop instance can be provided to the function). The default loop is blocked while running the loop.
  • Icicle\Loop\Events\SocketEventInterface and Icicle\Loop\Events\SignalInterface gained a setCallback() method that allows the callback invoked when an event occurs to be swapped without needing to create a new event.

Changes

  • The cancellation callable is no longer passed to the Icicle\Promise\Promise constructor, it should be returned from the resolver function passed to the constructor. This change was made to avoid the need to create reference variables to share values between functions. Instead values can just be used in the cancellation function returned from the resolver. The resolver function must return a callable or null.
  • Cancelling a promise is now an asynchronous task. Calling Icicle\Promise\Promise::cancel() does not immediately call the cancellation method (if given), it is called later (like a function registered with then()).
  • Icicle/Promise/PromiseInterface now includes an isCancelled() method. When a promise is cancelled, this method will return true once the promise has been cancelled. Note that if a child promise is rejected due to an $onRejected callable throwing after cancelling the parent promise, isCancelled() of the child promise will return false because the promise was not cancelled, it was rejected from the $onRejected callback.

Bug Fixes

  • Fixed issue where Icicle\Loop\SelectLoop would not dispatch a signal while blocking. The issue was fixed by adding a periodic timer that checks for signals that may have arrived. The interval of this timer can be set with Icicle\Loop\SelectLoop::signalInterval().

v0.7.1

18 Jul 17:35
Compare
Choose a tag to compare
  • Modified Icicle\Promise\Promise for better performance. The modified implementation eliminates the creation of one closure and only creates a queue of callbacks if more than one callback is registered to be invoked on fulfillment or rejection. No changes were made to functionality.

v0.7.0

02 Jul 05:18
Compare
Choose a tag to compare

Changes

  • Moved Stream and Socket components to separate repositories: icicleio/stream and icicleio/socket. No API changes were made in these components from v0.6.0. If your project depends on these components, just add them as a requirement with composer.

v0.6.0

01 Jul 15:39
Compare
Choose a tag to compare

Changes

  • The methods Icicle\Stream\ReadableStreamInterface::pipe(), Icicle\Socket\Client\ClientInterface::enableCrypto(), and Icicle\Socket\Client\ConnectorInterface::connect() now return a Generator instead of an Icicle\Promise\PromiseInterface object. The returned generator can be yielded directly in a coroutine. A promise can be created from these methods if desired by passing the returned Generator to the Icicle\Coroutine\Coroutine constructor (e.g., $coroutine = new Coroutine($connector->connect($host, $port)). This change was made for better performance with yield from in PHP 7.
  • Icicle\Loop\Events\SocketEventInterface::listen() now uses 0 to indicate no timeout.
  • All stream methods have a $timeout parameter, not only stream sockets. All $timeout parameters now use 0 to indicate no timeout.
  • Icicle\Stream\ReadableStreamInterface::read() and Icicle\Stream\ReadableStreamInterface::pipe() now use 0 to specify any number of bytes instead of null.
  • Icicle\Loop\schedule() was renamed to Icicle\Loop\queue() and Icicle\Loop\maxScheduleDepth() was renamed to Icicle\Loop\maxQueueDepth(). Icicle\Loop\maxQueueDepth() requires a $depth parameter (use 0 for unlimited). The previous depth is still returned.
  • Icicle\Coroutine\async() was renamed to Icicle\Coroutine\wrap().
  • Icicle\Promise\join() was renamed to Icicle\Promise\all().
  • Exceptions were remodeled based on the exception hierarchy coming in PHP 7. Each component has a class Exception and Error that extends \Exception. The empty ExceptionInterface classes were eliminated. Several classes were renamed to use the Error suffix to indicate they represent coding errors and generally should not be caught except for cleanup/logging.
  • The protocol unix no longer needs to be explicitly specified when creating or connecting to a unix socket. Using null for the port is sufficient.

v0.5.3

20 Jun 20:01
Compare
Choose a tag to compare

New Features

  • Added Promise\wait() function that can be used to synchronously wait for a promise to be resolved. The fulfillment value is returned or the rejection reason is thrown from the function. This function can be used to integrate Icicle into a synchronous environment, but generally should not be used in an active event loop.

Changes

  • Various performance improvements when executing scheduled callbacks, executing promise callbacks, and checking for coroutine completion or cancellation.

Bug Fixes

  • Added check in Datagram::send() on stream_socket_sendto() sending 0 bytes if the data was not immediately sent to prevent an infinite loop if the datagram is unexpectedly closed while waiting to send data.
  • Changed timer execution in SelectLoop to avoid timer drift.

v0.5.2

13 Jun 18:27
Compare
Choose a tag to compare

Changes

  • ReadableStreamInterface::pipe() implementations now use coroutines instead of Promise\iterate(), significantly improving performance. The Coroutine instance is returned from pipe(), so piping may be paused if desired.

v0.5.1

02 Jun 21:08
Compare
Choose a tag to compare

Bug Fixes

  • Fixed bug related to generators that never yield. If a generator was written in such a way that it may never yield, the coroutine was rejected even though the generator had not been run and could have yielded values under different circumstances. Now if a generator is immediately invalid, the coroutine is fulfilled with null instead of being rejected.

v0.5.0

31 May 03:30
Compare
Choose a tag to compare

New Features

  • Icicle\Socket\Datagram classes and interfaces added to documentation and can now be used.

Changes

  • The Loop facade class has been replaced by a set of functions defined in the Icicle\Loop namespace. Generally, calls to the Loop facade such as Loop::run() can be replaced with Loop\run() (using Icicle\Loop instead of Icicle\Loop\Loop). See the Loop documentation for more information.
  • Static functions in Icicle\Promise\Promise have been replaced with functions defined in the Icicle\Promise namespace. Calls such as Promise::resolve() can be replace with Promise\resolve() (using Icicle\Promise instead of Icicle\Promise\Promise). See the Promises documentation for more information.
  • Static functions in Icicle\Coroutine\Coroutine have been replaced with functions defined in the Icicle\Coroutine namespace. Like promises above, calls such as Coroutine::async() can be replaced with Coroutine\async() (using Icicle\Coroutine instead of Icicle\Coroutine\Coroutine). See the Coroutine documentation for more information.
  • Lazy promises should now be created with the function Icicle\Promise\lazy() instead of directly constructing a LazyPromise instance. Icicle\Promise\LazyPromise has been moved to Icicle\Promise\Structures\LazyPromise and should not be created directly, but rather is an implementation detail of Icicle\Promise\lazy().
  • The promise returned from Icicle\Socket\Server\Server::accept() will no longer be rejected with an AcceptException if accepting the client fails. The timeout option was also removed from this method, as retrying after a failed accept would make the timeout unreliable.
  • Removed tests from distributions after updating other components to no longer depend on test classes from this package. Use the --prefer-source option when installing with Composer if you wish to have tests included.

Bug Fixes

  • Updated stream closing methods to avoid constructing an exception object if there are no pending promises to be rejected.

v0.4.1

21 May 16:53
Compare
Choose a tag to compare

Changes

  • Added tests back into distributions so users could verify their setup and so other components could use base test classes. Removed again in v0.5.0.

v0.4.0

21 May 16:11
Compare
Choose a tag to compare

New Features

  • Process signals are now treated like other loop events and are represented by objects implementing Icicle\Loop\Events\SignalInterface. Use the Icicle\Loop\Loop::signal() method to create signal event objects. See the documentation for more information.
  • Added method isEmpty() to Icicle\Loop\Loop that determines if there are any events pending in the loop.
  • Support for unix sockets added to Icicle\Socket\Client\Connector by passing the file path as the first parameter and null for the port and adding 'protocol' => 'unix' to the array of options.
  • Support for unix sockets also added to Icicle\Socket\Server\ServerFactory by passing the file path as the first parameter and null for the port and adding 'protocol' => 'unix' to the array of options.
  • Added ability to restart timers if they were stopped using the start() method. Note that the methods on Icicle\Loop\Events\TimerInterface have changed (see Changes section).
  • Added execute() method to Icicle\Loop\Evnets\ImmediateInterface to execute the immediate again if desired.

Changes

  • The Event Emitter package is no longer a dependency since process signals have been refactored into event objects (see above). Icicle\Loop\LoopInterface no longer extends Icicle\EventEmitter\EventEmitterInterface.
  • Related to the above changes to signal handling, following methods have been removed from Icicle\Loop\Loop:
    • addSignalHandler()
    • removeSignalHandler()
    • removeAllSignalHandlers()
  • Icicle\Loop\Events\TimerInterface changed to support restarting timers. start() method added, cancel() renamed to stop().
  • Icicle\Loop\LoopInterface objects should no longer pass the socket resource to socket event callbacks. This only affects custom implementations of Icicle\Loop\LoopInterface, no changes need to be made to code using socket event objects.
  • Changed order of arguments to create timers in Icicle\Loop\LoopInterface to be consistent with other methods creating events. Again, this change only will affect custom loop implementations, not user code since argument order did not change in Icicle\Loop\Loop.