allocations 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b60f6178ed9431369c8bc4445f31d5ff1196fd0f
4
- data.tar.gz: 5299855c4bf14ff61c4abc047d42acdbee83eb39
3
+ metadata.gz: eb4fcbc39ec1eab5fe4831d66b372a71ea0d0d4a
4
+ data.tar.gz: 5abee9e95a64a77c97efce6ee84fc3423f83f4a5
5
5
  SHA512:
6
- metadata.gz: 31565e3a8fc1a26582491b14885041aaf37016b93962ed3149ce15e316f4aad7499c430af7c538cf4ef5672c71645e0e2ed55da74eba6eb4f179c55bc4ce0ae4
7
- data.tar.gz: 516095b00c662b3a3ab40f30d1f9c77d76c3e275cb2497691c2d405605a3fab4f8cb2a66fc97757ee69790cc82cb30f548f5b552cd139097388b7a521c0894a1
6
+ metadata.gz: c03ec7031bd717eac4bec3ff0939fec83549bec9eafa8696d76898fbe66d5a1d2809a63fce601b0007a5b4723d3029565eee001b48bcd76a9029144a51b9fe4e
7
+ data.tar.gz: d3eaf46688c14434715dc5b567a4da61eb7435e2e4c4bd904d27e357311a20088567d70d517fe0665148e0329bfe374513682f51f5dab4bc5f70edcdf0617c47
@@ -2,8 +2,6 @@
2
2
 
3
3
  st_table *object_counts;
4
4
 
5
- VALUE mutex;
6
-
7
5
  VALUE allocation_tracer;
8
6
  VALUE free_tracer;
9
7
 
@@ -25,12 +23,8 @@ void newobj_callback(VALUE tracepoint, void* data) {
25
23
  return;
26
24
  }
27
25
 
28
- rb_mutex_lock(mutex);
29
-
30
26
  st_lookup(object_counts, (st_data_t) klass, &count);
31
27
  st_insert(object_counts, (st_data_t) klass, count + 1);
32
-
33
- rb_mutex_unlock(mutex);
34
28
  }
35
29
 
36
30
  /**
@@ -47,8 +41,6 @@ void freeobj_callback(VALUE tracepoint, void* data) {
47
41
  VALUE obj = rb_tracearg_object(trace_arg);
48
42
  VALUE klass = RBASIC_CLASS(obj);
49
43
 
50
- rb_mutex_lock(mutex);
51
-
52
44
  if ( st_lookup(object_counts, (st_data_t) klass, &count) ) {
53
45
  if ( count > 0 && (count - 1) > 0) {
54
46
  st_insert(object_counts, (st_data_t) klass, count - 1);
@@ -58,8 +50,6 @@ void freeobj_callback(VALUE tracepoint, void* data) {
58
50
  st_delete(object_counts, (st_data_t*) &klass, NULL);
59
51
  }
60
52
  }
61
-
62
- rb_mutex_unlock(mutex);
63
53
  }
64
54
 
65
55
  /**
@@ -84,18 +74,12 @@ VALUE allocations_to_hash(VALUE self) {
84
74
  st_table *local_counts;
85
75
  VALUE hash;
86
76
 
87
- rb_mutex_lock(mutex);
88
-
89
77
  if ( !object_counts ) {
90
- rb_mutex_unlock(mutex);
91
-
92
78
  return rb_hash_new();
93
79
  }
94
80
 
95
81
  local_counts = st_copy(object_counts);
96
82
 
97
- rb_mutex_unlock(mutex);
98
-
99
83
  hash = rb_hash_new();
100
84
 
101
85
  st_foreach(local_counts, each_count, (st_data_t) hash);
@@ -112,11 +96,7 @@ VALUE allocations_to_hash(VALUE self) {
112
96
  * Allocations.start -> nil
113
97
  */
114
98
  VALUE allocations_start(VALUE self) {
115
- rb_mutex_lock(mutex);
116
-
117
99
  if ( rb_ivar_get(self, id_enabled) == Qtrue ) {
118
- rb_mutex_unlock(mutex);
119
-
120
100
  return Qnil;
121
101
  }
122
102
 
@@ -124,8 +104,6 @@ VALUE allocations_start(VALUE self) {
124
104
 
125
105
  rb_ivar_set(self, id_enabled, Qtrue);
126
106
 
127
- rb_mutex_unlock(mutex);
128
-
129
107
  rb_tracepoint_enable(allocation_tracer);
130
108
  rb_tracepoint_enable(free_tracer);
131
109
 
@@ -139,11 +117,7 @@ VALUE allocations_start(VALUE self) {
139
117
  * Allocations.stop -> nil
140
118
  */
141
119
  VALUE allocations_stop(VALUE self) {
142
- rb_mutex_lock(mutex);
143
-
144
120
  if ( rb_ivar_get(self, id_enabled) != Qtrue ) {
145
- rb_mutex_unlock(mutex);
146
-
147
121
  return Qnil;
148
122
  }
149
123
 
@@ -158,8 +132,6 @@ VALUE allocations_stop(VALUE self) {
158
132
 
159
133
  rb_ivar_set(self, id_enabled, Qfalse);
160
134
 
161
- rb_mutex_unlock(mutex);
162
-
163
135
  return Qnil;
164
136
  }
165
137
 
@@ -172,14 +144,10 @@ VALUE allocations_stop(VALUE self) {
172
144
  VALUE allocations_enabled_p(VALUE self) {
173
145
  VALUE enabled = Qfalse;
174
146
 
175
- rb_mutex_lock(mutex);
176
-
177
147
  if ( rb_ivar_get(self, id_enabled) == Qtrue ) {
178
148
  enabled = Qtrue;
179
149
  }
180
150
 
181
- rb_mutex_unlock(mutex);
182
-
183
151
  return enabled;
184
152
  }
185
153
 
@@ -192,8 +160,6 @@ void Init_liballocations() {
192
160
  free_tracer = rb_tracepoint_new(Qnil, RUBY_INTERNAL_EVENT_FREEOBJ,
193
161
  freeobj_callback, NULL);
194
162
 
195
- mutex = rb_mutex_new();
196
-
197
163
  id_enabled = rb_intern("enabled");
198
164
 
199
165
  rb_define_singleton_method(mAllocations, "to_hash", allocations_to_hash, 0);
@@ -201,7 +167,6 @@ void Init_liballocations() {
201
167
  rb_define_singleton_method(mAllocations, "stop", allocations_stop, 0);
202
168
  rb_define_singleton_method(mAllocations, "enabled?", allocations_enabled_p, 0);
203
169
 
204
- rb_define_const(mAllocations, "MUTEX", mutex);
205
170
  rb_define_const(mAllocations, "ALLOCATION_TRACER", allocation_tracer);
206
171
  rb_define_const(mAllocations, "FREE_TRACER", free_tracer);
207
172
  }
@@ -1,3 +1,3 @@
1
1
  module Allocations
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allocations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yorick Peterse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-17 00:00:00.000000000 Z
11
+ date: 2015-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.4.8
104
+ rubygems_version: 2.2.5
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Tracking of retained objects in CRuby