mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-18 01:57:13 +00:00
Added test-ffi target, use it in CI (#9)
* Added test-ffi target, use it in CI * Added clang-format config, fixed RETURN_STRING API mismatch * Skip installing php and packages on the PHP docker images * Removed al2 job that was never going to work, and compiler tests * Fixed basic test for extension loading * Cleaned up lib structure, fixed tests * use test-ci target to conditionally test in GitHub * Use v0.8.1 of builder
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class for all native resources, tracks all outstanding resources
|
||||
* and provides basic leak checking
|
||||
*/
|
||||
abstract class NativeResource {
|
||||
protected static $crt = null;
|
||||
protected static $resources = [];
|
||||
protected $native = null;
|
||||
|
||||
function __construct() {
|
||||
if (is_null(self::$crt)) {
|
||||
try {
|
||||
self::$crt = new CRT();
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception while loading CRT: ', $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
self::$resources[spl_object_hash($this)] = 1;
|
||||
}
|
||||
|
||||
protected function acquire($handle) {
|
||||
$this->native = $handle;
|
||||
}
|
||||
|
||||
protected function release() {
|
||||
$this->native = null;
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
// Should have been destroyed and released by derived resource
|
||||
assert($this->native == null);
|
||||
unset(self::$resources[spl_object_hash($this)]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user