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
|
use Test2::V0 -no_srand => 1;
BEGIN { skip_all 'Test requires a threading Perl' unless eval q{ use threads; 1 } }
use FFI::CheckLib;
use FFI::Platypus;
use Config;
my $ffi = FFI::Platypus->new(lib => find_lib(lib => 'test', symbol => 'f0', libpath => 't/ffi' ));
sub f0
{
$ffi->function(f0 => ['uint8'] => 'uint8')->call(@_);
}
sub otherthread
{
my $val = f0(22);
undef $ffi;
$val;
}
ok 1;
is(threads->create(\&otherthread)->join(), 22, 'works in a thread');
is f0(24), 24, 'works in main thread';
done_testing;
|