Index: modules/thread/thread.fec =================================================================== RCS file: /cvsroot/ferite/ferite/modules/thread/thread.fec,v retrieving revision 1.19 diff -u -r1.19 thread.fec --- modules/thread/thread.fec 8 Mar 2003 23:01:08 -0000 1.19 +++ modules/thread/thread.fec 18 Oct 2003 23:18:23 -0000 @@ -36,6 +36,7 @@ #define SelfThread ((FeriteThread*)self->odata) #define SelfMutex ((AphexMutex*)self->odata) +#define SelfEvent ((AphexEvent*)self->odata) FeriteScript *ferite_thread_create_script( FeriteScript *script ); void ferite_thread_destroy_script( FeriteScript *parent, FeriteThread *ctx ); @@ -221,3 +222,74 @@ /** * !end */ + +/** + * !class Event + * !brief Events + */ +class Event +{ + /** + * !function Event + * !declaration native function Event() + * !brief The constructor + */ + native function Event() + { + SelfEvent = aphex_event_create(); + } + + native function Destructor() + { + if( SelfEvent != NULL ) + aphex_event_destroy( SelfEvent ); + SelfEvent = NULL; + } + + /** + * !function signal + * !declaration native function signal() + * !brief Cause an event to be broadcasted + * !description Signals any threads in wait or timedwait that it is okay to continue + * + */ + native function signal() + { + if( SelfEvent != NULL ) + aphex_event_signal( SelfEvent ); + } + + /** + * !function wait + * !declaration native function wait() + * !brief This thread will wait for a signal to be called + */ + native function wait() + { + if( SelfEvent != NULL ) + aphex_event_wait( SelfEvent ); + } + + /** + * !function timedwait + * !declaration native function timedwait( number seconds) + * !brief This thread will wait for a signal to be called + * !param number seconds The amount of time to wait in seconds + * !return true if a signal was caught, false otherwise + */ + native function timedwait( number seconds ) + { + if( SelfEvent != NULL ) + { + if( aphex_event_timedwait( SelfEvent, (long)seconds) == 0) + { + FE_RETURN_TRUE; + } + } + FE_RETURN_FALSE; + } +} +/** + * !end + */ +