msleep 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +22 -0
- data/ext/extconf.rb +5 -0
- data/ext/msleep.c +40 -0
- metadata +56 -0
data/README
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
= msleep
|
2
|
+
|
3
|
+
Copyright (c) 2009 SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Pause for N milliseconds.
|
8
|
+
|
9
|
+
== Example
|
10
|
+
|
11
|
+
require 'msleep'
|
12
|
+
|
13
|
+
msleep 500 # milliseconds
|
14
|
+
|
15
|
+
== Project Page
|
16
|
+
|
17
|
+
http://rubyforge.org/projects/msleep
|
18
|
+
|
19
|
+
== Source Code
|
20
|
+
|
21
|
+
http://coderepos.org/share/browser/lang/ruby/msleep
|
22
|
+
|
data/ext/extconf.rb
ADDED
data/ext/msleep.c
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#ifdef _WIN32
|
2
|
+
#include <windows.h>
|
3
|
+
#endif
|
4
|
+
|
5
|
+
#include <time.h>
|
6
|
+
#include <ruby.h>
|
7
|
+
|
8
|
+
static VALUE rb_msleep(VALUE self, VALUE vn) {
|
9
|
+
unsigned long n;
|
10
|
+
|
11
|
+
#ifndef _WIN32
|
12
|
+
unsigned long msec, sec;
|
13
|
+
struct timespec req;
|
14
|
+
#endif
|
15
|
+
|
16
|
+
n = FIX2LONG(vn);
|
17
|
+
|
18
|
+
#ifndef _WIN32
|
19
|
+
msec = n % 1000;
|
20
|
+
sec = (n - msec) / 1000;
|
21
|
+
|
22
|
+
req.tv_sec = sec;
|
23
|
+
req.tv_nsec = msec * 1000000;
|
24
|
+
|
25
|
+
if (nanosleep(&req, NULL) != 0) {
|
26
|
+
return Qnil;
|
27
|
+
}
|
28
|
+
#else
|
29
|
+
Sleep(n);
|
30
|
+
#endif
|
31
|
+
|
32
|
+
return vn;
|
33
|
+
}
|
34
|
+
|
35
|
+
#ifdef _WIN32
|
36
|
+
__declspec(dllexport)
|
37
|
+
#endif
|
38
|
+
void Init_msleep() {
|
39
|
+
rb_define_global_function("msleep", rb_msleep, 1);
|
40
|
+
}
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: msleep
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- winebarrel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-26 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: sgwr_dts@yahoo.co.jp
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- ext/extconf.rb
|
26
|
+
- ext/msleep.c
|
27
|
+
- README
|
28
|
+
has_rdoc: true
|
29
|
+
homepage: http://msleep.rubyforge.org
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options:
|
32
|
+
- --title
|
33
|
+
- msleep
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
requirements: []
|
49
|
+
|
50
|
+
rubyforge_project: msleep
|
51
|
+
rubygems_version: 1.3.1
|
52
|
+
signing_key:
|
53
|
+
specification_version: 2
|
54
|
+
summary: Pause for N milliseconds.
|
55
|
+
test_files: []
|
56
|
+
|