[ Previous ] [ Contents ] [ Index ] [ Next ]

Ns_WaitForEvent

Overview

Wait for an event

Syntax

    int Ns_WaitForEvent(
    Ns_Event * event, 
    Ns_Mutex * lock
    );

Description

Unlock the lock and wait for the event. This function blocks the current thread's execution until the event has been set and it can reacquire the lock. The mutex lock is locked before and after the call.

Examples

    static int ready = 0;
    static Ns_Event ev;
    static Ns_Mutex lock;
    
    void
    Init(void)
    {
    	Ns_InitializeMutex(&lock);
    	Ns_InitializeEvent(&ev);
    }
    
    void
    Waiter(void)
    {
    	Ns_LockMutex(&lock);
    	if (!ready) {
    		Ns_WaitForEvent(&ev, &lock);
    	}
    	Ns_UnlockMutex(&lock);
    	... resource ready ...
    }

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1998-99 America Online, Inc.