rmagick 7.1.7 → 7.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +164 -0
- data/README.md +12 -0
- data/Rakefile +1 -0
- data/ext/RMagick/extconf.rb +6 -2
- data/ext/RMagick/rmagick.cpp +55 -58
- data/ext/RMagick/rmagick.h +103 -56
- data/ext/RMagick/rmagick_gvl.cpp +1394 -0
- data/ext/RMagick/rmagick_gvl.h +4 -2
- data/ext/RMagick/rmagick_gvl.hpp +105 -0
- data/ext/RMagick/rmdraw.cpp +702 -294
- data/ext/RMagick/rmenum.cpp +59 -19
- data/ext/RMagick/rmfill.cpp +138 -47
- data/ext/RMagick/rmilist.cpp +387 -183
- data/ext/RMagick/rmimage.cpp +3554 -1711
- data/ext/RMagick/rminfo.cpp +305 -143
- data/ext/RMagick/rmkinfo.cpp +106 -29
- data/ext/RMagick/rmmain.cpp +744 -571
- data/ext/RMagick/rmmontage.cpp +151 -56
- data/ext/RMagick/rmpixel.cpp +115 -112
- data/ext/RMagick/rmstruct.cpp +147 -98
- data/ext/RMagick/rmutil.cpp +432 -93
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +82 -21
- data/lib/rvg/rvg.rb +1 -1
- data/sig/rmagick/_image_common_methods.rbs +1 -1
- data/sig/rmagick/enum.rbs +2 -0
- data/sig/rmagick/image.rbs +1 -0
- data/sig/rmagick/image_list.rbs +1 -0
- data/sig/rmagick/optional_method_arguments.rbs +1 -1
- metadata +4 -2
data/ext/RMagick/rmagick_gvl.h
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
#define _RMAGICK_GVL_H_
|
|
3
3
|
|
|
4
4
|
#include "ruby/thread.h"
|
|
5
|
+
#include "ruby/fiber/scheduler.h"
|
|
5
6
|
|
|
6
7
|
typedef void *(gvl_function_t)(void *);
|
|
7
8
|
|
|
8
9
|
#define GVL_FUNC(name) name##_gvl
|
|
9
10
|
#define GVL_STRUCT_TYPE(name) name##_args_t
|
|
10
|
-
#
|
|
11
|
-
|
|
11
|
+
#if defined(RB_NOGVL_OFFLOAD_SAFE) && defined(HAVE_RB_FIBER_SCHEDULER_BLOCKING_OPERATION_EXTRACT)
|
|
12
|
+
#define RMAGICK_OFFLOAD_SAFE 1
|
|
13
|
+
#endif
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
#define DEFINE_GVL_STRUCT1(name, type1) \
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#ifndef _RMAGICK_GVL_HPP_
|
|
2
|
+
#define _RMAGICK_GVL_HPP_
|
|
3
|
+
|
|
4
|
+
extern void rm_gvl_init(void);
|
|
5
|
+
extern void rm_gvl_check_readable(VALUE);
|
|
6
|
+
extern void rm_gvl_check_writable(VALUE);
|
|
7
|
+
extern bool rm_gvl_in_use(VALUE);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A call to an ImageMagick function without the GVL, which a Fiber scheduler
|
|
11
|
+
* with a worker pool may run on a worker thread. Register the Ruby objects the
|
|
12
|
+
* call uses and what the caller releases after it, then call run().
|
|
13
|
+
*/
|
|
14
|
+
class rm_gvl_call
|
|
15
|
+
{
|
|
16
|
+
public:
|
|
17
|
+
rm_gvl_call(gvl_function_t *fp, void *args);
|
|
18
|
+
|
|
19
|
+
rm_gvl_call &read(VALUE obj);
|
|
20
|
+
rm_gvl_call &update(VALUE obj);
|
|
21
|
+
rm_gvl_call &read_each(VALUE ary);
|
|
22
|
+
rm_gvl_call &update_each(VALUE ary);
|
|
23
|
+
rm_gvl_call &hold(VALUE obj, bool changes = false);
|
|
24
|
+
rm_gvl_call &release(ExceptionInfo *exception);
|
|
25
|
+
rm_gvl_call &release(ImageInfo *info);
|
|
26
|
+
rm_gvl_call &release(DrawInfo *draw_info);
|
|
27
|
+
rm_gvl_call &release(KernelInfo *kernel);
|
|
28
|
+
rm_gvl_call &destroy(Image *image);
|
|
29
|
+
rm_gvl_call &split(Image *images);
|
|
30
|
+
#if defined(IMAGEMAGICK_7)
|
|
31
|
+
rm_gvl_call &restore_mask(Image *image, ChannelType channel_mask);
|
|
32
|
+
#endif
|
|
33
|
+
rm_gvl_call &free_buffer(void *buffer);
|
|
34
|
+
rm_gvl_call &relinquish(void *memory);
|
|
35
|
+
rm_gvl_call &free_result();
|
|
36
|
+
rm_gvl_call &keep_thread(bool keep = true);
|
|
37
|
+
rm_gvl_call &cleanup(void (*release)(void *, intptr_t), void *ptr, intptr_t arg = 0);
|
|
38
|
+
|
|
39
|
+
template <typename T> T run();
|
|
40
|
+
|
|
41
|
+
bool uses(VALUE obj, bool update) const;
|
|
42
|
+
void restore() const;
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
enum ResultType { ResultIgnored, ResultImage, ResultMemory };
|
|
46
|
+
enum { MaxObjects = 4, MaxCleanups = 4 };
|
|
47
|
+
|
|
48
|
+
typedef struct
|
|
49
|
+
{
|
|
50
|
+
VALUE obj;
|
|
51
|
+
bool update;
|
|
52
|
+
bool each;
|
|
53
|
+
} object_t;
|
|
54
|
+
|
|
55
|
+
typedef struct
|
|
56
|
+
{
|
|
57
|
+
void (*release)(void *, intptr_t);
|
|
58
|
+
void *ptr;
|
|
59
|
+
intptr_t arg;
|
|
60
|
+
bool restore;
|
|
61
|
+
} cleanup_t;
|
|
62
|
+
|
|
63
|
+
gvl_function_t *fp;
|
|
64
|
+
void *args;
|
|
65
|
+
object_t objects[MaxObjects];
|
|
66
|
+
int nobjects;
|
|
67
|
+
cleanup_t cleanups[MaxCleanups];
|
|
68
|
+
int ncleanups;
|
|
69
|
+
ResultType result_type;
|
|
70
|
+
bool keep;
|
|
71
|
+
|
|
72
|
+
rm_gvl_call &add_object(VALUE obj, bool update, bool each);
|
|
73
|
+
rm_gvl_call &add_cleanup(void (*release)(void *, intptr_t), void *ptr, intptr_t arg, bool restore);
|
|
74
|
+
template <typename F> bool any_object(bool update_only, F f) const;
|
|
75
|
+
void *call(ResultType type);
|
|
76
|
+
void check_frozen_images(ResultType type);
|
|
77
|
+
void *call_body(ResultType type);
|
|
78
|
+
struct offload_frame *new_frame();
|
|
79
|
+
void *offload(ResultType type);
|
|
80
|
+
void check_images_idle(ResultType type);
|
|
81
|
+
void *call_here(ResultType type);
|
|
82
|
+
void unwind(ResultType type, void *result, bool abandoned = false);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
template <typename T>
|
|
86
|
+
T
|
|
87
|
+
rm_gvl_call::run()
|
|
88
|
+
{
|
|
89
|
+
return (T)(uintptr_t)call(result_type);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
template <> Image *rm_gvl_call::run<Image *>();
|
|
93
|
+
template <> void rm_gvl_call::run<void>();
|
|
94
|
+
|
|
95
|
+
//! declare the arguments of the GVL stub of name and an rm_gvl_call named var that calls it
|
|
96
|
+
#define DECLARE_GVL_CALL(var, name, ...) \
|
|
97
|
+
GVL_STRUCT_TYPE(name) var##_args = { __VA_ARGS__ }; \
|
|
98
|
+
rm_gvl_call var(GVL_FUNC(name), &var##_args)
|
|
99
|
+
|
|
100
|
+
//! declare the arguments of type and an rm_gvl_call named var that calls fp with them
|
|
101
|
+
#define DECLARE_GVL_CALL_FP(var, type, fp, ...) \
|
|
102
|
+
GVL_STRUCT_TYPE(type) var##_args = { __VA_ARGS__ }; \
|
|
103
|
+
rm_gvl_call var(fp, &var##_args)
|
|
104
|
+
|
|
105
|
+
#endif
|