diff -u -N -r ./spread-src-4.0.0rc2/docs/E_activate_fd.3 ./spread-doc/docs/E_activate_fd.3 --- ./spread-src-4.0.0rc2/docs/E_activate_fd.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_activate_fd.3 2006-09-20 14:19:11.000000000 -0700 @@ -0,0 +1,69 @@ +.TH E_activate_fd 3 "September 2006" "Spread Events" "User Manuals" +.SH NAME +E_activate_fd, E_deactivate_fd, E_set_active_threshhold E_num_active, \- file descriptor activity threshold functions. +.SH SYNOPSIS +.br +.B #include +.br +.BI "int E_activate_fd(int fd, int fd_type);" +.br +.BI "int E_deactivate_fd(int fd, int fd_type);" +.br +.BI "int E_set_active_threshhold(int priority);" +.br +.BI "int E_num_active(int priority);" +.SH DESCRIPTION +Callbacks can be enabled and disabled in two manners, firstly on a per-callback basis and secondly by setting a priority threshhold value where only callbacks above the priority threshhold are active. +.BI E_activate_fd +will activate the callback for the passed in +.I fd +and +.I fd_type +. If the callback was already active this call has no effect. However if the callback is below the current priority threshhold, this call will not be active until the priority threshhold is changed to include the callbacks priority. +.PP +.BI E_deactivate_fd +will de-activate the callback for the passed in +.I fd +and +.I fd_type +. If the callback was already de-activated this call has no effect. +.PP +.BI E_set_active_threshhold +sets the threshhold priority value where callbacks with priorities equal to or greater than the passed in +.I priority +will be active and those below it will not be active. Callbacks below the threshhold are not substracted from the value returned by +.BI E_num_active +. +.PP +.BI E_num_active +returns the number of currently active callbacks for the specified +.I priority +. Value priorities are: +.sp +.RS +.TB +.B LOW_PRIORITY +.br +.TB +.B MEDIUM_PRIORITY +.br +.TB +.B HIGH_PRIORITY +.RE +.PP +.SH RETURN VALUES +.BI E_activate_fd, +.BI E_deactivate_fd +return 0 on success and \-1 if the callback could not be found or other error. +.PP +.BI E_set_active_threshhold +returns the active priority threshhold value or \-1 on error. +.PP +.BI E_num_active +returns the number of active callbacks or \-1 on error. +.SH BUGS +.SH AUTHOR +manpage: Tracy Camp +.SH SEE ALSO +.BR spread_events (3) +.BR E_attach_fd (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/E_add_time.3 ./spread-doc/docs/E_add_time.3 --- ./spread-src-4.0.0rc2/docs/E_add_time.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_add_time.3 2006-09-20 13:33:30.000000000 -0700 @@ -0,0 +1,51 @@ +.TH E_add_time 3 "September 2006" "Spread Events" "User Manuals" +.SH NAME +E_get_time, E_add_time, E_sub_time, E_compare_time \- get and manipulate sp_time. +.SH SYNOPSIS +.B #include +.br +.BI "sp_time E_get_time(void);" +.br +.BI "sp_time E_add_time(sp_time t1, sp_time t2);" +.br +.BI "sp_time E_sub_time(sp_time t1, sp_time t2);" +.br +.BI "int E_compare_time(sp_time t1, sp_time t2);" +.SH DESCRIPTION +.B E_get_time +returns the current time as sp_time. +.PP +.B E_add_time +adds t2 to t1 and returns the resulting time. +.PP +.B E_sub_time +subtracts t2 from t1 and returns the resulting time. +.PP +.B E_compare_time +compares the two passed in times. The function returns 0 if the times +are equal, -1 if the first time is less than the second time and 1 if +the first time is greater than the second time. +.TP +sp_time is defined as follows: +.nf +.sp +typedef struct _sp_time { + long sec; + long usec; +} sp_time; +.fi +.SH RETURN VALUES +.BI E_get_time +.BI E_add_time +.BI E_sub_time +all return a sp_time. +.PP +.BI E_compare_time +returns 0 if the times are equal, -1 if the first time is less than +the second time and 1 if the first time is greater than the second time. +.SH BUGS +None. +.SH AUTHOR +manpage: Tracy Camp +.SH SEE ALSO +.BR spread_events (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/E_attach_fd.3 ./spread-doc/docs/E_attach_fd.3 --- ./spread-src-4.0.0rc2/docs/E_attach_fd.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_attach_fd.3 2006-09-20 14:18:40.000000000 -0700 @@ -0,0 +1,66 @@ +.TH E_attach_fd 3 "September 2006" "Spread Events" "User Manuals" +.SH NAME +E_attach_fd, E_detach_fd \- add and remove file descriptor event callbacks +.SH SYNOPSIS +.B #include +.br +.BI "int E_attach_fd(int fd, int fd_type, void (*callback_func)(int fd, int code, void *data), int code, void *data, int priority);" +.br +.BI "int E_detach_fd(int fd, int fd_type);" +.SH DESCRIPTION +.BI E_attach_fd +establishes a callback for the passed in file descriptor. The +.I fd_type +is a type field that controls what kind of events that the callback should be invoked for. Valid types are: +.sp +.RS +.TB +.B READ_FD +.br +.TB +.B WRITE_FD +.br +.TB +.B EXCEPT_FD +.RE +.PP +.I callback_func +has a prototype that looks like this: +.nf +.sp +void callback_func(int fd, int code, void *data); +.fi +.PP +The file descriptor, code and data parameters will be passed to the callback when invoked. The +.I priority +arguement controls the relative priority of the callback. Valid priorities are: +.sp +.RS +.TB +.B LOW_PRIORITY +.br +.TB +.B MEDIUM_PRIORITY +.br +.TB +.B HIGH_PRIORITY +.RE +.PP +It is possible to attach multiple callbacks to the same file descriptor with different or the same types and priorities. If a callback is attached is identical type and priority as a previous callback the previous callback is replaced with the new callback and data. E_attach_fd always leaves the callback activated, so if the fd had been deactivated previously it will become active as a side effect of this call. +.PP +Since a spread mbox is just a file descriptor it can be used with E_attach_fd. +.PP +.BI E_detach_fd +removes the callback for the passed in file descriptor for the passed in types. +.SH RETURN VALUES +.BI E_attach_fd +returns 0 on success, \-1 on error and 1 if a previously existing callback was replaced. +.BI E_detach_fd +returns 0 on success and \-1 on error. +.SH BUGS +None. +.SH AUTHOR +manpage: Tracy Camp +.SH SEE ALSO +.BR spread_events (3) +.BR E_attach_fd (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/E_compare_time.3 ./spread-doc/docs/E_compare_time.3 --- ./spread-src-4.0.0rc2/docs/E_compare_time.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_compare_time.3 2006-09-20 10:22:13.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_add_time.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/E_deactivate_fd.3 ./spread-doc/docs/E_deactivate_fd.3 --- ./spread-src-4.0.0rc2/docs/E_deactivate_fd.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_deactivate_fd.3 2006-09-20 10:24:12.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_activate_fd.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/E_delay.3 ./spread-doc/docs/E_delay.3 --- ./spread-src-4.0.0rc2/docs/E_delay.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_delay.3 2006-09-20 10:22:34.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_add_time.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/E_dequeue.3 ./spread-doc/docs/E_dequeue.3 --- ./spread-src-4.0.0rc2/docs/E_dequeue.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_dequeue.3 2006-09-20 11:22:04.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_queue.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/E_detach_fd.3 ./spread-doc/docs/E_detach_fd.3 --- ./spread-src-4.0.0rc2/docs/E_detach_fd.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_detach_fd.3 2006-09-20 11:21:42.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_attach_fd.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/E_exit_events.3 ./spread-doc/docs/E_exit_events.3 --- ./spread-src-4.0.0rc2/docs/E_exit_events.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_exit_events.3 2006-09-20 11:54:35.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_handle_events.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/E_get_time.3 ./spread-doc/docs/E_get_time.3 --- ./spread-src-4.0.0rc2/docs/E_get_time.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_get_time.3 2006-09-20 10:22:22.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_add_time.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/E_handle_events.3 ./spread-doc/docs/E_handle_events.3 --- ./spread-src-4.0.0rc2/docs/E_handle_events.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_handle_events.3 2006-09-20 13:33:13.000000000 -0700 @@ -0,0 +1,37 @@ +.TH E_handle_events 3 "September 2006" "Spread Events" "User Manuals" +.SH NAME +E_handle_events, E_exit_events \- start and stop the spread events loop +.SH SYNOPSIS +.B #include +.br +.B "void E_handle_events(void);" +.br +.B "void E_exit_events(void);" +.SH DESCRIPTION +.B E_handle_events +causes the calling thread to enter the spread events main loop. The call will not return until +.B E_exit_events +is called either in a callback or in another thread. Event callbacks will execute in the context of the calling thread. Generally your application should either be entirely event driven through the spread events library or create a thread to be the spread event loop. +.PP +.B E_exit_events +causes the thread that called +.B E_handle_events +to return to the caller. If a callback is in progress when this is called it will need to complete before this call has any effect. This call does not block and has no impact if +.B E_handle_events +has not been called or +.B E_exit_events +has previously been called and E_handle_events has not returned yet. + +.SH RETURN VALUES +.B E_handle_events +and +.B E_exit_events +both return void. +.SH BUGS +None. +.SH AUTHOR +manpage: Tracy Camp +.SH SEE ALSO +.BR spread_events (3) +.BR E_attach_fd (3) +.BR E_queue (fd) diff -u -N -r ./spread-src-4.0.0rc2/docs/E_init.3 ./spread-doc/docs/E_init.3 --- ./spread-src-4.0.0rc2/docs/E_init.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_init.3 2006-09-20 13:33:04.000000000 -0700 @@ -0,0 +1,19 @@ +.TH E_init 3 "September 2006" "Spread Events" "User Manuals" +.SH NAME +E_init \- initialize spread events library. +.SH SYNOPSIS +.B #include +.br +.BI E_init(void); +.SH DESCRIPTION +.B E_init +is the initial call to setup the spread events library for use. +.SH RETURN VALUES +Returns 0 on success. +.SH BUGS +.B E_init +is not tollerant of being called more than once per run time currently. +.SH AUTHOR +manpage: Tracy Camp +.SH SEE ALSO +.BR spread_events (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/E_num_active.3 ./spread-doc/docs/E_num_active.3 --- ./spread-src-4.0.0rc2/docs/E_num_active.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_num_active.3 2006-09-20 11:19:27.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_activate_fd.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/E_queue.3 ./spread-doc/docs/E_queue.3 --- ./spread-src-4.0.0rc2/docs/E_queue.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_queue.3 2006-09-20 14:18:57.000000000 -0700 @@ -0,0 +1,56 @@ +.TH E_queue 3 "September 2006" "Spread Events" "User Manuals" +.SH NAME +E_queue, E_dequeue \- add and remove time event callbacks +.SH SYNOPSIS +.br +.B #include +.br +.BI "int E_queue(void (*callback_func)(int code, void *data), int code, void *data, sp_time time_delta);" +.br +.BI "int E_dequeue(void (*callback_fun)(int code, void *data), int code, void *data);" +.SH DESCRIPTION +.BI E_queue +sets up the callback function to be called after a specified period of time. +.PP +.I callback_func +has a prototype that looks like this: +.nf +.sp +void callback_func(int code, void *data); +.fi +.PP +.I code +and +.I data +are passed to the callback_func. +.PP +.I time_delta +specifies in sp_time when the callback will be invoked. The actual time of callback is guaranteed to be after +.BI E_get_time ++ +.I time_delta +but not necissarily with any guarantee about when after that time. E_queue calls with identical args for the same time as a previous call to E_queue will replace the earlier callback and args. +.PP +.BI E_dequeue +will cancel the next occurance of +.I callback_func +with the specified +.I code +and +.I data +in the time queue. +.SH RETURN VALUES +.BI E_queue +always returns 0 +.br +.BI E_dequeue +returns 0 on success and \-1 on error. +.SH BUGS +None. +.SH AUTHOR +manpage: Tracy Camp +.SH SEE ALSO +.BR spread_events (3) +.BR E_get_time (3) +.BR E_attach_fd (3) +.BR E_detach_fd (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/E_set_active_threshhold.3 ./spread-doc/docs/E_set_active_threshhold.3 --- ./spread-src-4.0.0rc2/docs/E_set_active_threshhold.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_set_active_threshhold.3 2006-09-20 11:20:10.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_activate_fd.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/E_sub_time.3 ./spread-doc/docs/E_sub_time.3 --- ./spread-src-4.0.0rc2/docs/E_sub_time.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/E_sub_time.3 2006-09-20 10:21:47.000000000 -0700 @@ -0,0 +1,4 @@ +.\" Process this file with +.\" groff -man -Tascii foo.1 +.\" +.so man3/E_add_time.3 diff -u -N -r ./spread-src-4.0.0rc2/docs/Makefile.in ./spread-doc/docs/Makefile.in --- ./spread-src-4.0.0rc2/docs/Makefile.in 2006-03-02 13:28:36.000000000 -0800 +++ ./spread-doc/docs/Makefile.in 2006-09-20 11:19:59.000000000 -0700 @@ -30,6 +30,8 @@ MANPAGES_IN = SP_connect.3 SP_disconnect.3 SP_equal_group_ids.3 SP_error.3 SP_get_memb_info.3 SP_get_vs_sets_info.3 SP_get_vs_set_members.3 SP_join.3 SP_leave.3 SP_multicast.3 SP_multigroup_multicast.3 SP_multigroup_scat_multicast.3 SP_poll.3 SP_receive.3 SP_scat_get_memb_info.3 SP_scat_get_vs_sets_info.3 SP_scat_get_vs_set_members.3 SP_scat_multicast.3 SP_scat_receive.3 SP_version.3 libspread.3 spread.1 spuser.1 sptuser.1 spmonitor.1 spflooder.1 PAGENAMES = connect disconnect equal_group_ids error get_memb_info get_vs_sets_info get_vs_set_members join leave multicast multigroup_multicast multigroup_scat_multicast poll receive scat_get_memb_info scat_get_vs_sets_info scat_get_vs_set_members scat_multicast scat_receive +FLUSHPAGENAMES=connect disconnect error flush join leave more_msgs multicast poll receive scat_multicast scat_receive scat_subgroupcast scat_unicast subgroupcast unicast version +EVENTPAGENAMES=spread_events E_init E_handle_events E_exit_events E_queue E_attach_fd E_dequeue E_detach_fd E_sub_time E_add_time E_compare_time E_delay E_get_time E_activate_fd E_deactivate_fd E_set_active_threshhold E_num_active DOCFILES = DynamicConfiguration.txt MultithreadedClients.txt PORTING Short_Buffer_Handling.txt Win32BuildInstructions.pdf TODO @@ -93,10 +95,14 @@ do \ $(INSTALL) -m 644 SP_$$page.3.out $(DESTDIR)$(mandir)/$(mansubdir)3/SP_$$page.3; \ done - for page in connect disconnect error flush join leave more_msgs multicast poll receive scat_multicast scat_receive scat_subgroupcast scat_unicast subgroupcast unicast version; \ + for page in $(FLUSHPAGENAMES); \ do \ $(INSTALL) -m 644 $(srcdir)/flush/man/FL_$$page.3 $(DESTDIR)$(mandir)/$(mansubdir)3/FL_$$page.3; \ done + for page in $(EVENTPAGENAMES); \ + do \ + $(INSTALL) -m 644 $(srcdir)/$$page.3 $(DESTDIR)$(mandir)/$(mansubdir)3/$$page.3; \ + done install-files: $(buildtoolsdir)/mkinstalldirs $(DESTDIR)$(docdir) diff -u -N -r ./spread-src-4.0.0rc2/docs/SP_connect.3 ./spread-doc/docs/SP_connect.3 --- ./spread-src-4.0.0rc2/docs/SP_connect.3 2006-02-16 13:24:20.000000000 -0800 +++ ./spread-doc/docs/SP_connect.3 2006-09-20 09:34:22.000000000 -0700 @@ -123,4 +123,5 @@ .SH "SEE ALSO" .BR libspread (3) +.BR SP_disconnect (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/SP_disconnect.3 ./spread-doc/docs/SP_disconnect.3 --- ./spread-src-4.0.0rc2/docs/SP_disconnect.3 2006-02-16 13:24:20.000000000 -0800 +++ ./spread-doc/docs/SP_disconnect.3 2006-09-20 09:34:41.000000000 -0700 @@ -43,4 +43,5 @@ .SH "SEE ALSO" .BR libspread (3) +.BR SP_connect (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/SP_join.3 ./spread-doc/docs/SP_join.3 --- ./spread-src-4.0.0rc2/docs/SP_join.3 2006-02-16 13:24:20.000000000 -0800 +++ ./spread-doc/docs/SP_join.3 2006-09-20 09:35:05.000000000 -0700 @@ -3,7 +3,7 @@ .\" .TH SP_JOIN 3 "JULY 1998" SPREAD "User Manuals" .SH NAME -SP_join \- create connection between app and daemon +SP_join \- create connection between app and group .SH SYNOPSIS .B #include .br @@ -46,5 +46,6 @@ .br .SH "SEE ALSO" -.BR libspread (3) +.BR libspread (3) +.BR SP_leave(3) diff -u -N -r ./spread-src-4.0.0rc2/docs/SP_leave.3 ./spread-doc/docs/SP_leave.3 --- ./spread-src-4.0.0rc2/docs/SP_leave.3 2006-02-16 13:24:20.000000000 -0800 +++ ./spread-doc/docs/SP_leave.3 2006-09-20 09:35:18.000000000 -0700 @@ -3,7 +3,7 @@ .\" .TH SP_LEAVE 3 "JULY 1998" SPREAD "User Manuals" .SH NAME -SP_leave \- create connection between app and daemon +SP_leave \- destroy connection between app and group .SH SYNOPSIS .B #include .br @@ -46,5 +46,6 @@ .br .SH "SEE ALSO" -.BR libspread (3) +.BR libspread (3) +.BR SP_join(3) diff -u -N -r ./spread-src-4.0.0rc2/docs/SP_poll.3 ./spread-doc/docs/SP_poll.3 --- ./spread-src-4.0.0rc2/docs/SP_poll.3 2006-02-16 13:24:20.000000000 -0800 +++ ./spread-doc/docs/SP_poll.3 2006-09-20 09:35:48.000000000 -0700 @@ -31,4 +31,5 @@ .SH "SEE ALSO" .BR libspread (3) +.BR SP_receive (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/SP_receive.3 ./spread-doc/docs/SP_receive.3 --- ./spread-src-4.0.0rc2/docs/SP_receive.3 2006-03-02 10:27:37.000000000 -0800 +++ ./spread-doc/docs/SP_receive.3 2006-09-20 09:37:59.000000000 -0700 @@ -401,4 +401,6 @@ .SH "SEE ALSO" .BR libspread (3) - +.BR SP_scat_get_mem_info (3) +.BR SP_scat_get_vs_set_members (3) +.BR SP_scat_get_vs_sets_info (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/libspread.3 ./spread-doc/docs/libspread.3 --- ./spread-src-4.0.0rc2/docs/libspread.3 2006-02-16 13:24:20.000000000 -0800 +++ ./spread-doc/docs/libspread.3 2006-09-20 10:37:42.000000000 -0700 @@ -46,6 +46,7 @@ Spread Project .SH "SEE ALSO" .BR spread (1) +.BR spread_events (3) .BR SP_connect (3) .BR SP_disconnect (3) .BR SP_equal_group_ids (3) diff -u -N -r ./spread-src-4.0.0rc2/docs/sp_events.h ./spread-doc/docs/sp_events.h --- ./spread-src-4.0.0rc2/docs/sp_events.h 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/sp_events.h 2006-09-20 09:49:05.000000000 -0700 @@ -0,0 +1,104 @@ +/* + * The Spread Toolkit. + * + * The contents of this file are subject to the Spread Open-Source + * License, Version 1.0 (the ``License''); you may not use + * this file except in compliance with the License. You may obtain a + * copy of the License at: + * + * http://www.spread.org/license/ + * + * or in the file ``license.txt'' found in this distribution. + * + * Software distributed under the License is distributed on an AS IS basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Creators of Spread are: + * Yair Amir, Michal Miskin-Amir, Jonathan Stanton, John Schultz. + * + * Copyright (C) 1993-2006 Spread Concepts LLC + * + * All Rights Reserved. + * + * Major Contributor(s): + * --------------- + * Ryan Caudy rcaudy@gmail.com - contributions to process groups. + * Cristina Nita-Rotaru crisn@cs.purdue.edu - group communication security. + * Theo Schlossnagle jesus@omniti.com - Perl, autoconf, old skiplist. + * Dan Schoenblum dansch@cnds.jhu.edu - Java interface. + * + */ + + + +#ifndef INC_SP_EVENTS +#define INC_SP_EVENTS + +/* + User level code should NOT include this file directly. + Include sp.h instead. + Spread daemon level code should include this file directly and NOT include sp.h +*/ + + +/* Raise this number AND RECOMPILE events.c to handle more active FD's. + * This number limits the number of connections that + * can be handled. + */ +#define MAX_FD_EVENTS 2000 + +#define NUM_PRIORITY 3 + +#define LOW_PRIORITY 0 +#define MEDIUM_PRIORITY 1 +#define HIGH_PRIORITY 2 + +#define NUM_FDTYPES 3 + +#define READ_FD 0 +#define WRITE_FD 1 +#define EXCEPT_FD 2 + + +typedef struct dummy_time { + long sec; + long usec; +} sp_time; + +#ifndef NULL +#define NULL (void *)0 +#endif + +/* Event routines */ + +int E_init(void); +sp_time E_get_time(void); +sp_time E_sub_time( sp_time t, sp_time delta_t ); +sp_time E_add_time( sp_time t, sp_time delta_t ); +/* if t1 > t2 then returns 1; + if t1 < t2 then returns -1; + if t1 == t2 then returns 0; */ +int E_compare_time( sp_time t1, sp_time t2 ); +int E_queue( void (* func)( int code, void *data ), int code, void *data, + sp_time delta_time ); +/* Note: This does not dispose/free the data pointed at by the void + *data pointer */ +int E_dequeue( void (* func)( int code, void *data ), int code, + void *data ); +void E_delay( sp_time t ); + +int E_attach_fd( int fd, int fd_type, + void (* func)( int fd, int code, void *data), int code, + void *data, int priority ); +int E_detach_fd( int fd, int fd_type ); +int E_set_active_threshold( int priority ); +int E_activate_fd( int fd, int fd_type ); +int E_deactivate_fd( int fd, int fd_type ); +int E_num_active( int priority ); + +void E_handle_events(void); +void E_exit_events(void); + +#endif /* INC_SP_EVENTS */ diff -u -N -r ./spread-src-4.0.0rc2/docs/spread_events.3 ./spread-doc/docs/spread_events.3 --- ./spread-src-4.0.0rc2/docs/spread_events.3 1969-12-31 16:00:00.000000000 -0800 +++ ./spread-doc/docs/spread_events.3 2006-09-20 13:32:20.000000000 -0700 @@ -0,0 +1,81 @@ +.TH spread_events 3 "September 2006" "Sread Events" "USER_MANUALS" +.SH NAME +sp_events.h \- spread event handling library. +.SH SYNOPSIS +Spread provides a general purpose event handling library that enables applications to setup asychronous callbacks from time and file descriptor events. +.SH DESCRIPTION +The library works by establishing a set of timed and file based callbacks and then entering a main loop. It is possible to use a separate thread for the main loop and setup callbacks in other threads. +.SH EXAMPLES +.TP +Simple timer based callback: +.nf +.sp +#include + +/* our example timer callback */ +void +timer_callback(int code, void *data) +{ +sp_time callback_time = {10,0}; +/* + * Do some real work in here.... + */ + +/* Schedule another callback */ +E_queue(timer_callback, 0, NULL, callback_time); +} + +int +main(int argc, char *argv[]) +{ +sp_time callback_time = {10,0}; +E_init(); + +/* setup a callback to 'timer_callback' in 10 seconds */ +E_queue(timer_callback, 0, NULL, callback_time); + +E_handle_events(); +} +.fi +.TP +Simple fd based callback: +.nf +.sp +/* our example fd callback */ +void +fd_callback(int mbox, int code, void *data) +{ +/* + * Do some real work in here.... + * A common example of 'real work' in this + * case would be to call SP_poll() and SP_receive(). + */ +} + +int +main(int argc, char *argv[]) +{ +char private_name[MAX_GROUP_NAME]; +mailbox mbox; + +SP_connect("4803@localhost", "test", 0, 0, &fd, private_name); + +E_init(); + +E_attach_fd(fd, READ_FD, fd_callback, 0, NULL, 0); +E_handle_events(); +} +.fi +.PP +Though this example used a spread mailbox, the fd could be +any file descriptor. +.SH AUTHOR +manpage: Tracy Camp +.SH SEE ALSO +.BR E_init (3) +.BR E_handle_events (3) +.BR E_stop_events (3) +.BR E_attach_fd (3) +.BR E_detach_fd (3) +.BR E_queue (3) +.BR E_dequeue (3)