Permalink
Browse files

Use atomic increments for counters

  • Loading branch information...
1 parent a116e68 commit ce3aa529bcf6486f95f193235cf9c6ad6bef51d3 @dbussink dbussink committed Feb 26, 2013
Showing with 6 additions and 6 deletions.
  1. +6 −6 vm/shared_state.hpp
View
@@ -195,8 +195,8 @@ namespace rubinius {
}
int inc_global_serial(STATE) {
- SYNC(state);
- return ++global_serial_;
+ atomic::fetch_and_add(&global_serial_, (int)1);
+ return global_serial_;
}
uint32_t new_thread_id();
@@ -210,13 +210,13 @@ namespace rubinius {
}
unsigned int inc_class_count(STATE) {
- SYNC(state);
- return ++class_count_;
+ atomic::fetch_and_add(&class_count_, (unsigned int)1);
+ return class_count_;
}
uint64_t inc_method_count(STATE) {
- SYNC(state);
- return ++method_count_;
+ atomic::fetch_and_add(&method_count_, (uint64_t)1);
+ return method_count_;
}
int inc_primitive_hit(int primitive) {

0 comments on commit ce3aa52

Please sign in to comment.