/* -*- C++ -*- */ // $Id$ // ============================================================================ // // = LIBRARY // ace // // = FILENAME // Future_Set.h // // = AUTHOR (S) // John Tucker // // ============================================================================ #ifndef ACE_FUTURE_SET_H #include "ace/pre.h" #define ACE_FUTURE_SET_H #include /**/ "ace/Thread.h" #include /**/ "ace/Message_Queue.h" #include /**/ "ace/Future.h" #include /**/ "ace/Hash_Map_Manager.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #if defined (ACE_HAS_THREADS) template class ACE_Future_Set : public ACE_Future_Observer { // = TITLE // This class implements a mechanism which allows the values of // a collections of objects to be accessed by // reader threads as they become available. public: // = Initialization and termination methods. ACE_Future_Set (ACE_Message_Queue *future_notification_queue_ = 0); // Constructor. ~ACE_Future_Set (void); // Destructor. int is_empty (void) const; // Return 1 if their are no objects left on its queue and // 0 otherwise int insert (ACE_Future &future); // Enqueus the given into this objects queue when it is // readable. // // Returns 0 if the future is successfully inserted, 1 if the // future is already inserted, and -1 if failures occur. int next_readable (ACE_Future &result, ACE_Time_Value *tv = 0); // Wait up to time to get the . Note that must be // specified in absolute time rather than relative time.); get the // next that is readable. If = 0, the will block // forever. // // If a readable future becomes available, then the input result // will be assigned with it and 1 will will be returned. If the set // is empty, then 0 is returned. virtual void update (const ACE_Future &future); // Called by the subject in which we are subscribed to // when its value is written to. ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. private: // = Disallow these operations. ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Future_Set &)) ACE_UNIMPLEMENTED_FUNC (ACE_Future_Set (const ACE_Future_Set &)) typedef ACE_Future FUTURE; typedef ACE_Future_Rep FUTURE_REP; typedef ACE_Future_Holder FUTURE_HOLDER; typedef ACE_Pointer_Hash FUTURE_REP_HASH; typedef ACE_Equal_To FUTURE_REP_COMPARE; typedef ACE_Hash_Map_Manager_Ex FUTURE_HASH_MAP; FUTURE_HASH_MAP future_map_; // Map of , subjects, which have not been written to by // client's writer thread. ACE_Message_Queue *future_notification_queue_; // Message queue for notifying the reader thread of which // have been written to by client's writer thread. int delete_queue_; // Keeps track of whether we need to delete the message queue. }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) #include "ace/Future_Set.cpp" #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) #pragma implementation ("Future_Set.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #endif /* ACE_HAS_THREADS */ #include "ace/post.h" #endif /* ACE_FUTURE_SET_H */