… | |
… | |
115 | C<ev_embeddable_backends () & ev_supported_backends ()>, likewise for |
115 | C<ev_embeddable_backends () & ev_supported_backends ()>, likewise for |
116 | recommended ones. |
116 | recommended ones. |
117 | |
117 | |
118 | See the description of C<ev_embed> watchers for more info. |
118 | See the description of C<ev_embed> watchers for more info. |
119 | |
119 | |
120 | =item ev_set_allocator (void *(*cb)(void *ptr, long size)) |
120 | =item ev_set_allocator (void *(*cb)(void *ptr, size_t size)) |
121 | |
121 | |
122 | Sets the allocation function to use (the prototype is similar to the |
122 | Sets the allocation function to use (the prototype and semantics are |
123 | realloc C function, the semantics are identical). It is used to allocate |
123 | identical to the realloc C function). It is used to allocate and free |
124 | and free memory (no surprises here). If it returns zero when memory |
124 | memory (no surprises here). If it returns zero when memory needs to be |
125 | needs to be allocated, the library might abort or take some potentially |
125 | allocated, the library might abort or take some potentially destructive |
126 | destructive action. The default is your system realloc function. |
126 | action. The default is your system realloc function. |
127 | |
127 | |
128 | You could override this function in high-availability programs to, say, |
128 | You could override this function in high-availability programs to, say, |
129 | free some memory if it cannot allocate memory, to use a special allocator, |
129 | free some memory if it cannot allocate memory, to use a special allocator, |
130 | or even to sleep a while and retry until some memory is available. |
130 | or even to sleep a while and retry until some memory is available. |
131 | |
131 | |
132 | Example: replace the libev allocator with one that waits a bit and then |
132 | Example: replace the libev allocator with one that waits a bit and then |
133 | retries: better than mine). |
133 | retries: better than mine). |
134 | |
134 | |
135 | static void * |
135 | static void * |
136 | persistent_realloc (void *ptr, long size) |
136 | persistent_realloc (void *ptr, size_t size) |
137 | { |
137 | { |
138 | for (;;) |
138 | for (;;) |
139 | { |
139 | { |
140 | void *newptr = realloc (ptr, size); |
140 | void *newptr = realloc (ptr, size); |
141 | |
141 | |
… | |
… | |
1997 | |
1997 | |
1998 | If you need to shave off some kilobytes of code at the expense of some |
1998 | If you need to shave off some kilobytes of code at the expense of some |
1999 | speed, define this symbol to C<1>. Currently only used for gcc to override |
1999 | speed, define this symbol to C<1>. Currently only used for gcc to override |
2000 | some inlining decisions, saves roughly 30% codesize of amd64. |
2000 | some inlining decisions, saves roughly 30% codesize of amd64. |
2001 | |
2001 | |
|
|
2002 | =item EV_PID_HASHSIZE |
|
|
2003 | |
|
|
2004 | C<ev_child> watchers use a small hash table to distribute workload by |
|
|
2005 | pid. The default size is C<16> (or C<1> with C<EV_MINIMAL>), usually more |
|
|
2006 | than enough. If you need to manage thousands of children you might want to |
|
|
2007 | increase this value. |
|
|
2008 | |
2002 | =item EV_COMMON |
2009 | =item EV_COMMON |
2003 | |
2010 | |
2004 | By default, all watchers have a C<void *data> member. By redefining |
2011 | By default, all watchers have a C<void *data> member. By redefining |
2005 | this macro to a something else you can include more and other types of |
2012 | this macro to a something else you can include more and other types of |
2006 | members. You have to define it each time you include one of the files, |
2013 | members. You have to define it each time you include one of the files, |