EC_Thread_Flags.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 /**
00003  *  @file   EC_Thread_Flags.h
00004  *
00005  *  $Id: EC_Thread_Flags.h 75402 2006-11-15 16:43:47Z cleeland $
00006  *
00007  *  @author Chris Cleeland <cleeland@ociweb.com>
00008  *
00009  *  Encapsulate flags that can be used for creating threads.
00010  */
00011 
00012 #ifndef TAO_EC_THREAD_FLAGS_H
00013 #define TAO_EC_THREAD_FLAGS_H
00014 #include /**/ "ace/pre.h"
00015 
00016 #include /**/ "tao/orbconf.h"
00017 #include /**/ "tao/Versioned_Namespace.h"
00018 #include /**/ "orbsvcs/Event/event_serv_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 /*!
00027   \class TAO_EC_Thread_Flags
00028 
00029   \brief Parse thread flags from string to a long.
00030  
00031   Encapsulate flags used for creating threads with \a
00032   ACE_OS::thr_create and \a ACE_Task::activate.
00033 
00034   \note On platforms that do not support the thread schedulers, the
00035   ACE OS adaptation layer preserves the symbols for THR_SCHED_*, but
00036   defines them as zero.  Thus, on such platforms, setting a scheduler
00037   in the flags, then inquiring for the scheduler type will yield the
00038   same result as an unknown or unset scheduler.
00039 
00040   \bugs This should really be part of ACE or ACE_OS, and maybe someday
00041   it will, but right now it's not.
00042 
00043 */
00044 class TAO_RTEvent_Serv_Export TAO_EC_Thread_Flags
00045 {
00046 public:
00047   TAO_EC_Thread_Flags () { }
00048   /*! \brief See \a operator=() */
00049   TAO_EC_Thread_Flags (const char* symbolic_flags)
00050     { this->parse_symbols(symbolic_flags); }
00051   ~TAO_EC_Thread_Flags ();
00052 
00053   // Default Copy CTOR is fine.
00054 
00055   /*!
00056     \brief Assign a new set of symbolic flags, setting \a flags, \a scope, and \a sched as possible.
00057 
00058     The flags can be symbolic, separated by the vertical bar ('|').
00059     In case a platform supports a creation flag not available
00060     symbolically, the user can specify a numeric value any place a
00061     symbol could be used.
00062 
00063     \sa TAO_EC_Thread_Flags::supported_flags
00064 
00065     \note The \a sched value only gets set if the scheduler is specified using symbols.
00066   */
00067   const TAO_EC_Thread_Flags& operator= (const char* symbolic_flags)
00068     { this->parse_symbols(symbolic_flags); return *this; }
00069 
00070   /*!
00071     \brief Returns numeric equivalent of the thread flags suitable for passing to ACE_Task::activate.
00072   */
00073   long flags() const { return this->flags_; }
00074 
00075   /*!
00076     \brief Returns value of THR_SCOPE_* used, or zero if unknown.
00077   */
00078   long scope() const { return this->scope_; }
00079  
00080   /*!
00081     \brief Returns value of THR_SCHED_* used, or zero if unknown.
00082   */
00083   long sched() const { return this->sched_; }
00084 
00085   /// Synonym for flags(), i.e., syntactic sugar.
00086   operator long () const { return this->flags(); }
00087 
00088   /*!
00089     \brief Return an acceptable default priority for the scheduler returned by sched().
00090     \return the priority, or ACE_DEFAULT_THREAD_PRIORITY if the scheduler is unknown.
00091   */
00092   long default_priority () const;
00093  
00094 
00095 
00096   struct Supported_Flag
00097   {
00098     const char* n; /// Flag name, e.g., THR_NEW_LWP
00099     long        v; /// Flag value, i.e., actual symbol
00100   };
00101 
00102   // TETFSF == TAO_EC_THREAD_FLAGS_SUPPORTED_FLAGS
00103   static Supported_Flag supported_flags_[];
00104 
00105 protected:
00106   long flags_; /// Value of all flags OR'd together
00107   long scope_; /// Value of THR_SCOPE_*
00108   long sched_; /// Value of THR_SCHED_*
00109 
00110   void parse_symbols (const char* syms);
00111 };
00112 
00113 TAO_END_VERSIONED_NAMESPACE_DECL
00114 
00115 #include /**/ "ace/post.h"
00116 #endif /* TAO_EC_THREAD_FLAGS_H */

Generated on Tue Feb 2 17:44:06 2010 for TAO_RTEvent by  doxygen 1.4.7