Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 9b7cbd0

Browse files
authored
Revert "Shared channel"
1 parent 0444452 commit 9b7cbd0

File tree

5 files changed

+12
-29
lines changed

5 files changed

+12
-29
lines changed

src/AbstractGeneratedProxy.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
abstract class AbstractGeneratedProxy
1111
{
1212
private Channel $out;
13-
private string $hash;
1413

15-
final public function __construct(Channel $out, string $hash)
14+
final public function __construct(Channel $out)
1615
{
17-
$this->out = $out;
18-
$this->hash = $hash;
16+
$this->out = $out;
1917
}
2018

2119
/**
@@ -28,7 +26,6 @@ final protected function proxyCallToMainThread(string $method, array $args)
2826
$input = new Channel(1);
2927
$this->out->send(new Call(
3028
$input,
31-
$this->hash,
3229
$method,
3330
$args,
3431
));

src/Message/Call.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
final class Call
1010
{
1111
private Channel $channel;
12-
private string $hash;
1312
private string $method;
1413

1514
/** @var mixed[] */
@@ -18,10 +17,9 @@ final class Call
1817
/**
1918
* @param mixed[] $args
2019
*/
21-
public function __construct(Channel $channel, string $hash, string $method, array $args)
20+
public function __construct(Channel $channel, string $method, array $args)
2221
{
2322
$this->channel = $channel;
24-
$this->hash = $hash;
2523
$this->method = $method;
2624
$this->args = $args;
2725
}
@@ -31,11 +29,6 @@ public function channel(): Channel
3129
return $this->channel;
3230
}
3331

34-
public function hash(): string
35-
{
36-
return $this->hash;
37-
}
38-
3932
public function method(): string
4033
{
4134
return $this->method;

src/Proxy.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,21 @@
77
use parallel\Channel;
88
use ReactParallel\Factory;
99
use ReactParallel\ObjectProxy\Generated\ProxyList;
10-
use ReactParallel\ObjectProxy\Message\Call;
1110
use ReactParallel\ObjectProxy\Proxy\CallHandler;
12-
use Rx\Observable;
1311

1412
use function array_key_exists;
15-
use function spl_object_hash;
1613

1714
final class Proxy extends ProxyList
1815
{
1916
private const HASNT_PROXYABLE_INTERFACE = false;
2017

21-
private Channel $output;
22-
private Observable $outputStream;
18+
private Factory $factory;
2319
private CallHandler $callHandler;
2420

2521
public function __construct(Factory $factory)
2622
{
27-
$this->output = new Channel(Channel::Infinite);
28-
$this->outputStream = $factory->streams()->channel($this->output)->share();
29-
$this->callHandler = new CallHandler($this);
23+
$this->factory = $factory;
24+
$this->callHandler = new CallHandler($this);
3025
}
3126

3227
public function has(string $interface): bool
@@ -40,14 +35,15 @@ public function create(object $object, string $interface): object
4035
throw NonExistentInterface::create($interface);
4136
}
4237

43-
$hash = spl_object_hash($object);
44-
$this->outputStream->filter(static fn (Call $call): bool => $call->hash() === $hash)->subscribe(
38+
$output = new Channel(Channel::Infinite);
39+
40+
$this->factory->streams()->channel($output)->subscribe(
4541
($this->callHandler)($object, $interface)
4642
);
4743

4844
$class = self::KNOWN_INTERFACE[$interface];
4945

5046
/** @psalm-suppress InvalidStringClass */
51-
return new $class($this->output, $hash);
47+
return new $class($output);
5248
}
5349
}

tests/Message/CallTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ final class CallTest extends AsyncTestCase
1818
public function getters(): void
1919
{
2020
$channel = new Channel(1);
21-
$hash = 'haajshdkjlsajkl';
2221
$method = 'hammer';
2322
$args = [time()];
2423

25-
$call = new Call($channel, $hash, $method, $args);
24+
$call = new Call($channel, $method, $args);
2625

2726
self::assertSame($channel, $call->channel());
28-
self::assertSame($hash, $call->hash());
2927
self::assertSame($method, $call->method());
3028
self::assertSame($args, $call->args());
3129
}

tests/Proxy/CallHandlerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ public function logger(): void
4040
});
4141
$callHandler = new Proxy\CallHandler($proxy);
4242
$time = time();
43-
$hash = 'asljdjaslkdhklasdslkadskl';
4443
$channel = new Channel(1);
45-
$call = new Call($channel, $hash, 'get', [LoggerInterface::class]);
44+
$call = new Call($channel, 'get', [LoggerInterface::class]);
4645

4746
$loop->futureTick(static function () use ($container, $callHandler, $call): void {
4847
($callHandler)($container, ContainerInterface::class)($call);

0 commit comments

Comments
 (0)