forked from krakjoe/pthreads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhacking-serials.phpt
51 lines (42 loc) · 1.25 KB
/
hacking-serials.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--TEST--
Check graceful serialization of Threaded objects as members of non Threaded objects
--DESCRIPTION--
We don't need to serialize Threaded objects when they are set as members of other Threaded
objects. However, a non-threaded object who has a Threaded object as a member must still serialize
the Threaded object when that non-threaded object is set as a member of yet another Threaded object.
So while Threaded objects can store other Threaded objects without hacky serialization routines, normal objects
still require a hack.
This test ensures the hack is right.
--FILE--
<?php
class Wrapper {
public $worker;
public function __construct() {
$this->worker = new Worker;
$this->worker->start();
}
public function stack(Collectable $work) {
$this->worker->stack($work);
}
public function shutdown() {
$this->worker->shutdown();
}
}
class Work extends Threaded {
public $wrapper;
public function __construct(Wrapper $wrapper) {
$this->wrapper = $wrapper;
}
public function stack() {
$this->wrapper->stack($this);
}
public function run() {
echo "Foo\n";
}
}
$wrapper = new Wrapper;
$work = new Work($wrapper);
$work->stack();
$wrapper->shutdown();
--EXPECT--
Foo