diff --git a/Gemfile b/Gemfile index c5337ce..611a2d8 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,6 @@ source 'https://rubygems.org' group :development do gem 'rake' - gem 'rake-compiler' gem 'sinatra', require: false gem 'slim', require: false end diff --git a/Rakefile b/Rakefile index 9ad444d..9af881f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,5 @@ require 'bundler/gem_tasks' require 'rake/testtask' -require 'rake/extensiontask' - -Rake::ExtensionTask.new('sidetiq_ext') Rake::TestTask.new do |t| t.pattern = 'test/**/test_*.rb' diff --git a/ext/sidetiq_ext/extconf.rb b/ext/sidetiq_ext/extconf.rb deleted file mode 100644 index ff68125..0000000 --- a/ext/sidetiq_ext/extconf.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rbconfig' -require 'mkmf' -create_makefile('sidetiq_ext') - diff --git a/ext/sidetiq_ext/sidetiq_ext.c b/ext/sidetiq_ext/sidetiq_ext.c deleted file mode 100644 index 4723f25..0000000 --- a/ext/sidetiq_ext/sidetiq_ext.c +++ /dev/null @@ -1,97 +0,0 @@ -#include -#include -#include "sidetiq_ext.h" - -#ifdef __APPLE__ -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include -#endif - -VALUE msidetiq; -VALUE esidetiq_error; -VALUE csidetiq_clock; - -#ifdef __APPLE__ -static mach_timebase_info_data_t clock_gettime_inf; - -typedef enum { - CLOCK_REALTIME, - CLOCK_MONOTONIC, - CLOCK_PROCESS_CPUTIME_ID, - CLOCK_THREAD_CPUTIME_ID -} clockid_t; - -int clock_gettime(clockid_t clk_id, struct timespec *tp) -{ - kern_return_t ret; - clock_serv_t clk; - clock_id_t clk_serv_id; - mach_timespec_t tm; - uint64_t start, end, delta, nano; - int retval = -1; - - switch (clk_id) { - case CLOCK_REALTIME: - case CLOCK_MONOTONIC: - clk_serv_id = clk_id == CLOCK_REALTIME ? CALENDAR_CLOCK : SYSTEM_CLOCK; - if (KERN_SUCCESS == (ret = host_get_clock_service(mach_host_self(), clk_serv_id, &clk))) { - if (KERN_SUCCESS == (ret = clock_get_time(clk, &tm))) { - tp->tv_sec = tm.tv_sec; - tp->tv_nsec = tm.tv_nsec; - retval = 0; - } - } - if (KERN_SUCCESS != ret) { - errno = EINVAL; - retval = -1; - } - break; - case CLOCK_PROCESS_CPUTIME_ID: - case CLOCK_THREAD_CPUTIME_ID: - start = mach_absolute_time(); - if (clk_id == CLOCK_PROCESS_CPUTIME_ID) { - getpid(); - } else { - sched_yield(); - } - end = mach_absolute_time(); - delta = end - start; - if (0 == clock_gettime_inf.denom) { - mach_timebase_info(&clock_gettime_inf); - } - nano = delta * clock_gettime_inf.numer / clock_gettime_inf.denom; - tp->tv_sec = nano * 1e-9; - tp->tv_nsec = nano - (tp->tv_sec * 1e9); - retval = 0; - break; - default: - errno = EINVAL; - retval = -1; - } - return retval; -} -#endif - -static VALUE sidetiq_gettime(VALUE self) -{ - struct timespec time; - assert(clock_gettime(CLOCK_REALTIME, &time) == 0); - return rb_time_nano_new(time.tv_sec, time.tv_nsec); -} - -void Init_sidetiq_ext() -{ - msidetiq = rb_define_module("Sidetiq"); - esidetiq_error = rb_define_class_under(msidetiq, "Error", rb_eStandardError); - csidetiq_clock = rb_define_class_under(msidetiq, "Clock", rb_cObject); - rb_define_private_method(csidetiq_clock, "clock_gettime", sidetiq_gettime, 0); -} - diff --git a/ext/sidetiq_ext/sidetiq_ext.h b/ext/sidetiq_ext/sidetiq_ext.h deleted file mode 100644 index 6793fe6..0000000 --- a/ext/sidetiq_ext/sidetiq_ext.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __SIDETIQ_EXT_H__ -#define __SIDETIQ_EXT_H__ -#include - -void Init_sidetiq_ext(); -static VALUE sidetiq_gettime(VALUE self); - -/* module Sidetiq */ -extern VALUE msidetiq; - -/* class Sidetiq::Error < StandardError */ -extern VALUE esidetiq_error; - -/* class Sidetiq::Clock */ -extern VALUE csidetiq_clock; - -#endif diff --git a/lib/sidetiq.rb b/lib/sidetiq.rb index 5d745cc..a4960e4 100644 --- a/lib/sidetiq.rb +++ b/lib/sidetiq.rb @@ -7,9 +7,6 @@ require 'singleton' require 'ice_cube' require 'sidekiq' -# c extensions -require 'sidetiq_ext' - # internal require 'sidetiq/config' require 'sidetiq/clock' diff --git a/lib/sidetiq/clock.rb b/lib/sidetiq/clock.rb index 561de18..75f4d4c 100644 --- a/lib/sidetiq/clock.rb +++ b/lib/sidetiq/clock.rb @@ -67,9 +67,6 @@ module Sidetiq # Public: Returns the current time used by the clock. # - # Sidetiq::Clock uses `clock_gettime()` on UNIX systems and - # `mach_absolute_time()` on Mac OS X. - # # Examples # # gettime @@ -77,7 +74,7 @@ module Sidetiq # # Returns a Time instance. def gettime - Sidetiq.config.utc ? clock_gettime.utc : clock_gettime + Sidetiq.config.utc ? Time.now.utc : Time.now end # Public: Starts the clock unless it is already running. diff --git a/test/test_errors.rb b/test/test_errors.rb deleted file mode 100644 index a8c919b..0000000 --- a/test/test_errors.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_relative 'helper' - -class TestErrors < Sidetiq::TestCase - def test_error_superclass - assert_equal StandardError, Sidetiq::Error.superclass - end -end