Releases: icicleio/icicle
Releases · icicleio/icicle
v0.8.0
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
andIcicle\Loop\Events\SignalInterface
gained asetCallback()
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 acallable
ornull
. - 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 withthen()
). Icicle/Promise/PromiseInterface
now includes anisCancelled()
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 withIcicle\Loop\SelectLoop::signalInterval()
.
v0.7.1
- 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
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
Changes
- The methods
Icicle\Stream\ReadableStreamInterface::pipe()
,Icicle\Socket\Client\ClientInterface::enableCrypto()
, andIcicle\Socket\Client\ConnectorInterface::connect()
now return aGenerator
instead of anIcicle\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 returnedGenerator
to theIcicle\Coroutine\Coroutine
constructor (e.g.,$coroutine = new Coroutine($connector->connect($host, $port))
. This change was made for better performance withyield from
in PHP 7. Icicle\Loop\Events\SocketEventInterface::listen()
now uses0
to indicate no timeout.- All stream methods have a
$timeout
parameter, not only stream sockets. All$timeout
parameters now use0
to indicate no timeout. Icicle\Stream\ReadableStreamInterface::read()
andIcicle\Stream\ReadableStreamInterface::pipe()
now use0
to specify any number of bytes instead ofnull
.Icicle\Loop\schedule()
was renamed toIcicle\Loop\queue()
andIcicle\Loop\maxScheduleDepth()
was renamed toIcicle\Loop\maxQueueDepth()
.Icicle\Loop\maxQueueDepth()
requires a$depth
parameter (use0
for unlimited). The previous depth is still returned.Icicle\Coroutine\async()
was renamed toIcicle\Coroutine\wrap()
.Icicle\Promise\join()
was renamed toIcicle\Promise\all()
.- Exceptions were remodeled based on the exception hierarchy coming in PHP 7. Each component has a class
Exception
andError
that extends\Exception
. The emptyExceptionInterface
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. Usingnull
for the port is sufficient.
v0.5.3
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()
onstream_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
v0.5.1
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
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 asLoop::run()
can be replaced withLoop\run()
(usingIcicle\Loop
instead ofIcicle\Loop\Loop
). See the Loop documentation for more information. - Static functions in
Icicle\Promise\Promise
have been replaced with functions defined in theIcicle\Promise
namespace. Calls such asPromise::resolve()
can be replace withPromise\resolve()
(usingIcicle\Promise
instead ofIcicle\Promise\Promise
). See the Promises documentation for more information. - Static functions in
Icicle\Coroutine\Coroutine
have been replaced with functions defined in theIcicle\Coroutine
namespace. Like promises above, calls such asCoroutine::async()
can be replaced withCoroutine\async()
(usingIcicle\Coroutine
instead ofIcicle\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 aLazyPromise
instance.Icicle\Promise\LazyPromise
has been moved toIcicle\Promise\Structures\LazyPromise
and should not be created directly, but rather is an implementation detail ofIcicle\Promise\lazy()
. - The promise returned from
Icicle\Socket\Server\Server::accept()
will no longer be rejected with anAcceptException
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
v0.4.0
New Features
- Process signals are now treated like other loop events and are represented by objects implementing
Icicle\Loop\Events\SignalInterface
. Use theIcicle\Loop\Loop::signal()
method to create signal event objects. See the documentation for more information. - Added method
isEmpty()
toIcicle\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 andnull
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 andnull
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 onIcicle\Loop\Events\TimerInterface
have changed (see Changes section). - Added
execute()
method toIcicle\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 extendsIcicle\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 tostop()
.Icicle\Loop\LoopInterface
objects should no longer pass the socket resource to socket event callbacks. This only affects custom implementations ofIcicle\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 inIcicle\Loop\Loop
.