Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  specify next release
  use configured stream capabilities in the Sockets
  give access to base OS config
  • Loading branch information
Baptouuuu committed Feb 25, 2023
2 parents 4d596ad + 4ceec19 commit eb9ba0b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 3.7.0 - 2023-02-25

### Added

- `Innmind\OperatingSystem\OperatingSystem\Unix::config()` (declared as `internal`)

### Changed

- `Innmind\OperatingSystem\Sockets\Unix` now uses the stream `Capabilities` from the `Config`

## 3.6.0 - 2023-02-11

### Added
Expand Down
10 changes: 9 additions & 1 deletion src/OperatingSystem/Unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public static function of(Clock $clock, Config $config = null): self
return new self($clock, $config ?? Config::of());
}

/**
* @internal
*/
public function config(): Config
{
return $this->config;
}

public function clock(): Clock
{
return $this->clock;
Expand Down Expand Up @@ -86,7 +94,7 @@ public function ports(): Ports

public function sockets(): Sockets
{
return $this->sockets ??= Sockets\Unix::of();
return $this->sockets ??= Sockets\Unix::of($this->config);
}

public function remote(): Remote
Expand Down
26 changes: 20 additions & 6 deletions src/Sockets/Unix.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

namespace Innmind\OperatingSystem\Sockets;

use Innmind\OperatingSystem\Sockets;
use Innmind\OperatingSystem\{
Sockets,
Config,
};
use Innmind\Socket\{
Address\Unix as Address,
Server,
Expand All @@ -15,13 +18,16 @@

final class Unix implements Sockets
{
private function __construct()
private Config $config;

private function __construct(Config $config)
{
$this->config = $config;
}

public static function of(): self
public static function of(Config $config = null): self
{
return new self;
return new self($config ?? Config::of());
}

public function open(Address $address): Maybe
Expand All @@ -45,9 +51,17 @@ public function connectTo(Address $address): Maybe
public function watch(ElapsedPeriod $timeout = null): Watch
{
if (\is_null($timeout)) {
return Watch\Select::waitForever();
return $this
->config
->streamCapabilities()
->watch()
->waitForever();
}

return Watch\Select::timeoutAfter($timeout);
return $this
->config
->streamCapabilities()
->watch()
->timeoutAfter($timeout);
}
}

0 comments on commit eb9ba0b

Please sign in to comment.