Search
Project
General
Profile
Home
Projects
Help
Sign in
Register
Search
:
Ruby
All Projects
Ruby
Overview
Activity
Roadmap
Issues
Repository
Download (612 Bytes)
Bug #22428
» slow_op.c
watson1978 (Shizuo Fujita)
, 10/12/2026 08:22 AM
#include
<ruby.h>
#include
<ruby/thread.h>
#include
<stdint.h>
#include
<time.h>
static
void
*
slow
(
void
*
arg
)
{
long
ms
=
(
long
)(
intptr_t
)
arg
;
struct
timespec
ts
=
{
ms
/
1000
,
(
ms
%
1000
)
*
1000000L
};
while
(
nanosleep
(
&
ts
,
&
ts
)
!=
0
)
{
}
return
(
void
*
)
1
;
}
static
VALUE
slow_op_run
(
VALUE
self
,
VALUE
ms
)
{
void
*
ran
=
rb_nogvl
(
slow
,
(
void
*
)(
intptr_t
)
NUM2LONG
(
ms
),
RUBY_UBF_IO
,
NULL
,
RB_NOGVL_OFFLOAD_SAFE
);
return
ran
?
Qtrue
:
Qfalse
;
}
void
Init_slow_op
(
void
)
{
VALUE
mod
=
rb_define_module
(
"SlowOp"
);
rb_define_module_function
(
mod
,
"run"
,
slow_op_run
,
1
);
}
« Previous
1
2
Next »
(2-2/2)
Loading...