Skip to content

Commit

Permalink
Enhanced code generation tools to support Python classes
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Sep 6, 2024
1 parent c4c887c commit befc6da
Show file tree
Hide file tree
Showing 26 changed files with 630 additions and 995 deletions.
26 changes: 26 additions & 0 deletions examples/lib/thread.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
require_once __DIR__ . '/../../vendor/autoload.php';

$thread_n = 4;
$threads = [];

$time = PyCore::import('time');

/**
* !!! WARNING !!!
* phpy does not support multithreading,
* this program will crash
*/
for ($i = 0; $i < $thread_n; $i++) {
$thread = new python\threading\Thread(target: function () use ($i, $time) {
$n = 10;
while ($n--) {
$time->sleep(1);
echo "[Thread#{$i}]\thello world\n";
}
});
$thread->start();
$threads[] = $thread;
echo "Thread#{$i} is started\n";
}

Loading

0 comments on commit befc6da

Please sign in to comment.