Skip to content

Commit

Permalink
Add Closable interface (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski authored Apr 3, 2022
1 parent 4b444cc commit dc327dd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Closable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Amp;

interface Closable
{
/**
* Closes the resource, marking it as unusable.
* Whether pending operations are aborted or not is implementation dependent.
*/
public function close(): void;

/**
* Returns whether this resource has been closed.
*
* @return bool {@code true} if closed, otherwise {@code false}
*/
public function isClosed(): bool;

/**
* Registers a callback that is invoked when this resource is closed.
*
* @param \Closure():void $onClose
*/
public function onClose(\Closure $onClose): void;
}

0 comments on commit dc327dd

Please sign in to comment.