Signaler::DeleteOnIntr( void * )

Removes a function previously registered using OnIntr() from the list.

Virtual?

No

 

Class

Signaler

 

Arguments

void *ptr

Pointer to the data item with which the original function was registered

Returns

void

 

See also

Signaler::OnIntr() Signaler::Intr()

Example

#include <unistd.h>    // for sleep()
#include <stdhdrs.h>
#include <strbuf.h>
#include <signaler.h>

class MyClass
{
    public:
    void         Set( StrPtr *d ) { data = *d; }
    const StrPtr *Get()           { return &data; }
    void         Identify()       { printf( "I'm %s\n", data.Text() ); }

    private:
    StrBuf       data;
};

static void InterruptHandler( void *p )
{
    MyClass      *m = ( MyClass * )p;
    m->Identify();
}

int main( int argc, char **argv )
{
    StrBuf   data;
    MyClass  *list[ 5 ];

    for ( int i = 1; i <= 5; i++ )
    {
        data.Set( "Object" );
        data << i;

        MyClass   *p = new MyClass;
        list[ i - 1 ] = p;

        p->Set( &data );

        signaler.OnIntr( InterruptHandler, (void *)p );
    }

    // Unregister Object 3
    signaler.DeleteOnIntr( list[ 2 ] );

    printf( "Hit ^C to fire the interrupt handler\n" );
    for ( ; ; )
        sleep( 60 );

    exit( 0 );
}