… | |
… | |
505 | =item ev_loop_fork (loop) |
505 | =item ev_loop_fork (loop) |
506 | |
506 | |
507 | Like C<ev_default_fork>, but acts on an event loop created by |
507 | Like C<ev_default_fork>, but acts on an event loop created by |
508 | C<ev_loop_new>. Yes, you have to call this on every allocated event loop |
508 | C<ev_loop_new>. Yes, you have to call this on every allocated event loop |
509 | after fork, and how you do this is entirely your own problem. |
509 | after fork, and how you do this is entirely your own problem. |
|
|
510 | |
|
|
511 | =item int ev_is_default_loop (loop) |
|
|
512 | |
|
|
513 | Returns true when the given loop actually is the default loop, false otherwise. |
510 | |
514 | |
511 | =item unsigned int ev_loop_count (loop) |
515 | =item unsigned int ev_loop_count (loop) |
512 | |
516 | |
513 | Returns the count of loop iterations for the loop, which is identical to |
517 | Returns the count of loop iterations for the loop, which is identical to |
514 | the number of times libev did poll for new events. It starts at C<0> and |
518 | the number of times libev did poll for new events. It starts at C<0> and |
… | |
… | |
2078 | is that the author does not know of a simple (or any) algorithm for a |
2082 | is that the author does not know of a simple (or any) algorithm for a |
2079 | multiple-writer-single-reader queue that works in all cases and doesn't |
2083 | multiple-writer-single-reader queue that works in all cases and doesn't |
2080 | need elaborate support such as pthreads. |
2084 | need elaborate support such as pthreads. |
2081 | |
2085 | |
2082 | That means that if you want to queue data, you have to provide your own |
2086 | That means that if you want to queue data, you have to provide your own |
2083 | queue. And here is how you would implement locking: |
2087 | queue. But at least I can tell you would implement locking around your |
|
|
2088 | queue: |
2084 | |
2089 | |
2085 | =over 4 |
2090 | =over 4 |
2086 | |
2091 | |
2087 | =item queueing from a signal handler context |
2092 | =item queueing from a signal handler context |
2088 | |
2093 | |
… | |
… | |
2125 | |
2130 | |
2126 | =item queueing from a thread context |
2131 | =item queueing from a thread context |
2127 | |
2132 | |
2128 | The strategy for threads is different, as you cannot (easily) block |
2133 | The strategy for threads is different, as you cannot (easily) block |
2129 | threads but you can easily preempt them, so to queue safely you need to |
2134 | threads but you can easily preempt them, so to queue safely you need to |
2130 | emply a traditional mutex lock, such as in this pthread example: |
2135 | employ a traditional mutex lock, such as in this pthread example: |
2131 | |
2136 | |
2132 | static ev_async mysig; |
2137 | static ev_async mysig; |
2133 | static pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER; |
2138 | static pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER; |
2134 | |
2139 | |
2135 | static void |
2140 | static void |