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

Commit caf6034

Browse files
committed
Drop interface from generated proxies
Since we've this information available in the main thread we no longer need to send this across frm the worker threads anymore.
1 parent 23cf2a0 commit caf6034

5 files changed

Lines changed: 6 additions & 32 deletions

File tree

src/AbstractGeneratedProxy.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ final public function __construct(Channel $out, string $hash)
2626
*
2727
* @return mixed
2828
*/
29-
final protected function proxyCallToMainThread(string $interface, string $method, array $args)
29+
final protected function proxyCallToMainThread(string $method, array $args)
3030
{
3131
$input = new Channel(1);
3232
$call = new Call(
3333
$input,
3434
$this->hash,
3535
spl_object_hash($this),
36-
$interface,
3736
$method,
3837
$args,
3938
);
@@ -44,10 +43,10 @@ final protected function proxyCallToMainThread(string $interface, string $method
4443
return $result;
4544
}
4645

47-
final protected function notifyMainThreadAboutDestruction(string $interface): void
46+
final protected function notifyMainThreadAboutDestruction(): void
4847
{
4948
try {
50-
$this->out->send(new Destruct($this->hash, spl_object_hash($this), $interface));
49+
$this->out->send(new Destruct($this->hash, spl_object_hash($this)));
5150
} catch (Channel\Error\Closed $closed) {
5251
// @ignoreException
5352
}

src/Composer/InterfaceProxier.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,6 @@ private function transformInterfaceIntoClass(Node\Stmt\Interface_ $interface): N
145145
new Node\Expr\MethodCall(
146146
new Node\Expr\Variable('this'),
147147
'notifyMainThreadAboutDestruction',
148-
[
149-
new Node\Arg(
150-
new Node\Scalar\String_($this->interfaceName),
151-
),
152-
],
153148
)
154149
),
155150
)->makePublic()->makeFinal()->getNode();
@@ -187,9 +182,6 @@ private function populateMethod(Node\Stmt\ClassMethod $method): Node\Stmt\ClassM
187182
new Node\Expr\Variable('this'),
188183
'proxyCallToMainThread',
189184
[
190-
new Node\Arg(
191-
new Node\Scalar\String_($this->interfaceName),
192-
),
193185
new Node\Arg(
194186
new Node\Expr\ConstFetch(
195187
new Node\Name('__FUNCTION__'),

src/Message/Call.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ final class Call
1212

1313
private string $hash;
1414
private string $objectHash;
15-
private string $interface;
1615

1716
private string $method;
1817

@@ -22,12 +21,11 @@ final class Call
2221
/**
2322
* @param mixed[] $args
2423
*/
25-
public function __construct(Channel $channel, string $hash, string $objectHash, string $interface, string $method, array $args)
24+
public function __construct(Channel $channel, string $hash, string $objectHash, string $method, array $args)
2625
{
2726
$this->channel = $channel;
2827
$this->hash = $hash;
2928
$this->objectHash = $objectHash;
30-
$this->interface = $interface;
3129
$this->method = $method;
3230
$this->args = $args;
3331
}
@@ -47,11 +45,6 @@ public function objectHash(): string
4745
return $this->objectHash;
4846
}
4947

50-
public function interface(): string
51-
{
52-
return $this->interface;
53-
}
54-
5548
public function method(): string
5649
{
5750
return $this->method;

src/Message/Destruct.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ final class Destruct
88
{
99
private string $hash;
1010
private string $objectHash;
11-
private string $interface;
1211

13-
public function __construct(string $hash, string $objectHash, string $interface)
12+
public function __construct(string $hash, string $objectHash)
1413
{
1514
$this->hash = $hash;
1615
$this->objectHash = $objectHash;
17-
$this->interface = $interface;
1816
}
1917

2018
public function hash(): string
@@ -26,9 +24,4 @@ public function objectHash(): string
2624
{
2725
return $this->objectHash;
2826
}
29-
30-
public function interface(): string
31-
{
32-
return $this->interface;
33-
}
3427
}

tests/Message/CallTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace ReactParallel\Tests\ObjectProxy\Message;
66

77
use parallel\Channel;
8-
use Psr\Log\LoggerInterface;
98
use ReactParallel\ObjectProxy\Message\Call;
109
use WyriHaximus\AsyncTestUtilities\AsyncTestCase;
1110

@@ -23,16 +22,14 @@ public function getters(): void
2322
$channel = new Channel(1);
2423
$hash = bin2hex(random_bytes(1024));
2524
$objectHash = bin2hex(random_bytes(1024));
26-
$interface = LoggerInterface::class;
2725
$method = 'hammer';
2826
$args = [time()];
2927

30-
$call = new Call($channel, $hash, $objectHash, $interface, $method, $args);
28+
$call = new Call($channel, $hash, $objectHash, $method, $args);
3129

3230
self::assertSame($channel, $call->channel());
3331
self::assertSame($hash, $call->hash());
3432
self::assertSame($objectHash, $call->objectHash());
35-
self::assertSame($interface, $call->interface());
3633
self::assertSame($method, $call->method());
3734
self::assertSame($args, $call->args());
3835
}

0 commit comments

Comments
 (0)