Skip to content

Commit 015b7ca

Browse files
committed
Remove postponed job APIs deprecated for 2 years
1 parent 3185786 commit 015b7ca

File tree

4 files changed

+0
-195
lines changed

4 files changed

+0
-195
lines changed

ext/-test-/postponed_job/postponed_job.c

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -35,38 +35,6 @@ pjob_callback(void *data)
3535
rb_ary_push(ary, INT2FIX(counter));
3636
}
3737

38-
static VALUE
39-
pjob_register(VALUE self, VALUE obj)
40-
{
41-
counter = 0;
42-
rb_postponed_job_register(0, pjob_callback, (void *)obj);
43-
rb_gc_start();
44-
counter++;
45-
rb_gc_start();
46-
counter++;
47-
rb_gc_start();
48-
counter++;
49-
return self;
50-
}
51-
52-
static void
53-
pjob_one_callback(void *data)
54-
{
55-
VALUE ary = (VALUE)data;
56-
Check_Type(ary, T_ARRAY);
57-
58-
rb_ary_push(ary, INT2FIX(1));
59-
}
60-
61-
static VALUE
62-
pjob_register_one(VALUE self, VALUE obj)
63-
{
64-
rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
65-
rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
66-
rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
67-
return self;
68-
}
69-
7038
static VALUE
7139
pjob_call_direct(VALUE self, VALUE obj)
7240
{
@@ -83,48 +51,6 @@ pjob_call_direct(VALUE self, VALUE obj)
8351

8452
static void pjob_noop_callback(void *data) { }
8553

86-
static VALUE
87-
pjob_register_one_same(VALUE self)
88-
{
89-
rb_gc_start();
90-
int r1 = rb_postponed_job_register_one(0, pjob_noop_callback, NULL);
91-
int r2 = rb_postponed_job_register_one(0, pjob_noop_callback, NULL);
92-
int r3 = rb_postponed_job_register_one(0, pjob_noop_callback, NULL);
93-
VALUE ary = rb_ary_new();
94-
rb_ary_push(ary, INT2FIX(r1));
95-
rb_ary_push(ary, INT2FIX(r2));
96-
rb_ary_push(ary, INT2FIX(r3));
97-
return ary;
98-
}
99-
100-
#ifdef HAVE_PTHREAD_H
101-
#include <pthread.h>
102-
103-
static void *
104-
pjob_register_in_c_thread_i(void *obj)
105-
{
106-
rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
107-
rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
108-
rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
109-
return NULL;
110-
}
111-
112-
static VALUE
113-
pjob_register_in_c_thread(VALUE self, VALUE obj)
114-
{
115-
pthread_t thread;
116-
if (pthread_create(&thread, NULL, pjob_register_in_c_thread_i, (void *)obj)) {
117-
return Qfalse;
118-
}
119-
120-
if (pthread_join(thread, NULL)) {
121-
return Qfalse;
122-
}
123-
124-
return Qtrue;
125-
}
126-
#endif
127-
12854
static void
12955
pjob_preregistered_callback(void *data)
13056
{
@@ -216,13 +142,7 @@ void
216142
Init_postponed_job(VALUE self)
217143
{
218144
VALUE mBug = rb_define_module("Bug");
219-
rb_define_module_function(mBug, "postponed_job_register", pjob_register, 1);
220-
rb_define_module_function(mBug, "postponed_job_register_one", pjob_register_one, 1);
221145
rb_define_module_function(mBug, "postponed_job_call_direct", pjob_call_direct, 1);
222-
rb_define_module_function(mBug, "postponed_job_register_one_same", pjob_register_one_same, 0);
223-
#ifdef HAVE_PTHREAD_H
224-
rb_define_module_function(mBug, "postponed_job_register_in_c_thread", pjob_register_in_c_thread, 1);
225-
#endif
226146
rb_define_module_function(mBug, "postponed_job_preregister_and_call_with_sleep", pjob_preregister_and_call_with_sleep, 1);
227147
rb_define_module_function(mBug, "postponed_job_preregister_and_call_without_sleep", pjob_preregister_and_call_without_sleep, 1);
228148
rb_define_module_function(mBug, "postponed_job_preregister_multiple_times", pjob_preregister_multiple_times, 0);

include/ruby/debug.h

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -754,59 +754,6 @@ rb_postponed_job_handle_t rb_postponed_job_preregister(unsigned int flags, rb_po
754754
*/
755755
void rb_postponed_job_trigger(rb_postponed_job_handle_t h);
756756

757-
/**
758-
* Schedules the given `func` to be called with `data` when Ruby next checks for
759-
* interrupts. If this function is called multiple times in between Ruby checking
760-
* for interrupts, then `func` will be called only once with the `data` value from
761-
* the first call to this function.
762-
*
763-
* Like `rb_postponed_job_trigger`, the context in which the job is called
764-
* holds the GVL and can allocate Ruby objects.
765-
*
766-
* This method essentially has the same semantics as:
767-
*
768-
* ```
769-
* rb_postponed_job_trigger(rb_postponed_job_preregister(func, data));
770-
* ```
771-
*
772-
* @note Previous versions of Ruby promised that the (`func`, `data`) pairs would
773-
* be executed as many times as they were registered with this function; in
774-
* reality this was always subject to race conditions and this function no
775-
* longer provides this guarantee. Instead, multiple calls to this function
776-
* can be coalesced into a single execution of the passed `func`, with the
777-
* most recent `data` registered at that time passed in.
778-
*
779-
* @deprecated This interface implies that arbitrarily many `func`'s can be enqueued
780-
* over the lifetime of the program, whilst in reality the registration
781-
* slots for postponed jobs are a finite resource. This is made clearer
782-
* by the `rb_postponed_job_preregister` and `rb_postponed_job_trigger`
783-
* functions, and a future version of Ruby might delete this function.
784-
*
785-
* @param[in] flags Unused and ignored.
786-
* @param[in] func Job body.
787-
* @param[in,out] data Passed as-is to `func`.
788-
* @retval 0 Postponed job registration table is full. Failed.
789-
* @retval 1 Registration succeeded.
790-
* @post The passed job will run on the next interrupt check.
791-
*/
792-
RBIMPL_ATTR_DEPRECATED(("use rb_postponed_job_preregister and rb_postponed_job_trigger"))
793-
int rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void *data);
794-
795-
/**
796-
* Identical to `rb_postponed_job_register`
797-
*
798-
* @deprecated This is deprecated for the same reason as `rb_postponed_job_register`
799-
*
800-
* @param[in] flags Unused and ignored.
801-
* @param[in] func Job body.
802-
* @param[in,out] data Passed as-is to `func`.
803-
* @retval 0 Postponed job registration table is full. Failed.
804-
* @retval 1 Registration succeeded.
805-
* @post The passed job will run on the next interrupt check.
806-
*/
807-
RBIMPL_ATTR_DEPRECATED(("use rb_postponed_job_preregister and rb_postponed_job_trigger"))
808-
int rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func, void *data);
809-
810757
/** @} */
811758

812759
/**

test/-ext-/postponed_job/test_postponed_job.rb

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,4 @@ def test_multiple_preregistration_with_new_data
3333
assert_equal [3, 4], values
3434
RUBY
3535
end
36-
37-
def test_legacy_register
38-
assert_separately([], __FILE__, __LINE__, <<-'RUBY')
39-
require '-test-/postponed_job'
40-
direct, registered = [], []
41-
42-
Bug.postponed_job_call_direct(direct)
43-
Bug.postponed_job_register(registered)
44-
45-
assert_equal([0], direct)
46-
assert_equal([3], registered)
47-
48-
Bug.postponed_job_register_one(ary = [])
49-
assert_equal [1], ary
50-
RUBY
51-
end
52-
53-
def test_legacy_register_one_same
54-
assert_separately([], __FILE__, __LINE__, <<-'RUBY')
55-
require '-test-/postponed_job'
56-
# Registering the same job three times should result in three of the same handle
57-
handles = Bug.postponed_job_register_one_same
58-
assert_equal [handles[0]], handles.uniq
59-
RUBY
60-
end
61-
62-
if Bug.respond_to?(:postponed_job_register_in_c_thread)
63-
def test_legacy_register_in_c_thread
64-
assert_separately([], __FILE__, __LINE__, <<-'RUBY')
65-
require '-test-/postponed_job'
66-
assert Bug.postponed_job_register_in_c_thread(ary = [])
67-
assert_equal [1], ary
68-
RUBY
69-
end
70-
end
7136
end

vm_trace.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,33 +1958,6 @@ rb_postponed_job_trigger(rb_postponed_job_handle_t h)
19581958
RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(get_valid_ec(vm));
19591959
}
19601960

1961-
1962-
static int
1963-
pjob_register_legacy_impl(unsigned int flags, rb_postponed_job_func_t func, void *data)
1964-
{
1965-
/* We _know_ calling preregister from a signal handler like this is racy; what is
1966-
* and is not promised is very exhaustively documented in debug.h */
1967-
rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, func, data);
1968-
if (h == POSTPONED_JOB_HANDLE_INVALID) {
1969-
return 0;
1970-
}
1971-
rb_postponed_job_trigger(h);
1972-
return 1;
1973-
}
1974-
1975-
int
1976-
rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void *data)
1977-
{
1978-
return pjob_register_legacy_impl(flags, func, data);
1979-
}
1980-
1981-
int
1982-
rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func, void *data)
1983-
{
1984-
return pjob_register_legacy_impl(flags, func, data);
1985-
}
1986-
1987-
19881961
void
19891962
rb_postponed_job_flush(rb_vm_t *vm)
19901963
{

0 commit comments

Comments
 (0)