ward


An os_ward is a synchronization mechanism that allows threads to wait on a group of handles or one handle out of the group to become posted before proceeding. A thread can wait on handles by calling any of the three wait methods. Wards are useful in situations in which more than one event or condition must be satisfied before proceeding.

Instances of the handle type, os_handle_t , must be obtained using  os_ward::handle_for() static method passing a descriptor as the argument. The handle type works very much the same as an os_event_semaphore . Handles are tracked by the ward and are used to notify waiting threads of occurrences of events or changes in conditions.

The compiler must be able to support multiple template partial specialization and OS_NO_PARTIAL_SPECIALIZATION must NOT be defined to use this class.

Library

Thread<ToolKit>

Declaration

#include <ospace/thread/ward.h>

class os_ward

Typedefs

typedef os_sentry< os_desc_t > os_handle_t;

Interface

handle_for
/* static */ os_handle_t handle_for( os_desc_t& descriptor )
Returns an os_handle_t for descriptor .
print
/* static */ void print( ostream& stream ) const
Prints to stream .
wait_for_multiple_objects
/* static */ int wait_for_multiple_objects( int count , os_handle_t* handle , bool waitall )
Waits until any handle in  handle becomes posted and returns the index if handle is false , otherwise waits until all handles become posted and returns 0 .
wait_for_single_object
/* static */ int wait_for_single_object( os_handle_t handle )
Waits until the handle becomes posted. If the handle is already in a posted state, returns 0 immediately.

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.