ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.128 by root, Fri Feb 1 13:53:56 2008 UTC vs.
Revision 1.130 by root, Wed Feb 6 18:34:24 2008 UTC

2078is that the author does not know of a simple (or any) algorithm for a 2078is that the author does not know of a simple (or any) algorithm for a
2079multiple-writer-single-reader queue that works in all cases and doesn't 2079multiple-writer-single-reader queue that works in all cases and doesn't
2080need elaborate support such as pthreads. 2080need elaborate support such as pthreads.
2081 2081
2082That means that if you want to queue data, you have to provide your own 2082That means that if you want to queue data, you have to provide your own
2083queue. And here is how you would implement locking: 2083queue. But at least I can tell you would implement locking around your
2084queue:
2084 2085
2085=over 4 2086=over 4
2086 2087
2087=item queueing from a signal handler context 2088=item queueing from a signal handler context
2088 2089
2125 2126
2126=item queueing from a thread context 2127=item queueing from a thread context
2127 2128
2128The strategy for threads is different, as you cannot (easily) block 2129The strategy for threads is different, as you cannot (easily) block
2129threads but you can easily preempt them, so to queue safely you need to 2130threads but you can easily preempt them, so to queue safely you need to
2130emply a traditional mutex lock, such as in this pthread example: 2131employ a traditional mutex lock, such as in this pthread example:
2131 2132
2132 static ev_async mysig; 2133 static ev_async mysig;
2133 static pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER; 2134 static pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER;
2134 2135
2135 static void 2136 static void
2942=item Priority handling: O(number_of_priorities) 2943=item Priority handling: O(number_of_priorities)
2943 2944
2944Priorities are implemented by allocating some space for each 2945Priorities are implemented by allocating some space for each
2945priority. When doing priority-based operations, libev usually has to 2946priority. When doing priority-based operations, libev usually has to
2946linearly search all the priorities, but starting/stopping and activating 2947linearly search all the priorities, but starting/stopping and activating
2947watchers becomes O(1) w.r.t. prioritiy handling. 2948watchers becomes O(1) w.r.t. priority handling.
2948 2949
2949=item Sending an ev_async: O(1) 2950=item Sending an ev_async: O(1)
2950 2951
2951=item Processing ev_async_send: O(number_of_async_watchers) 2952=item Processing ev_async_send: O(number_of_async_watchers)
2952 2953

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines