00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00047 #ifndef STLSOFT_INCL_STLSOFT_SYNCH_HPP_CONCEPTS
00048 #define STLSOFT_INCL_STLSOFT_SYNCH_HPP_CONCEPTS
00049 
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define STLSOFT_VER_STLSOFT_HPP_SYNCH_HPP_CONCEPTS_FWD_MAJOR       1
00052 # define STLSOFT_VER_STLSOFT_HPP_SYNCH_HPP_CONCEPTS_FWD_MINOR       0
00053 # define STLSOFT_VER_STLSOFT_HPP_SYNCH_HPP_CONCEPTS_FWD_REVISION    3
00054 # define STLSOFT_VER_STLSOFT_HPP_SYNCH_HPP_CONCEPTS_FWD_EDIT        11
00055 #endif 
00056 
00057 
00058 
00059 
00060 
00061 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00062 # include <stlsoft/stlsoft.h>
00063 #endif 
00064 #ifndef STLSOFT_INCL_STLSOFT_META_HPP_YESNO
00065 # include <stlsoft/meta/yesno.hpp>
00066 #endif 
00067 
00068 
00069 
00070 
00071 
00072 #ifndef _STLSOFT_NO_NAMESPACE
00073 namespace stlsoft
00074 {
00075 #endif 
00076 
00077 
00078 
00079 
00080 
00085 #if 0
00086 struct synchronisation_type_tag
00087 {};
00088 #endif 
00089 
00096 struct synchronisable_object_tag
00097 
00098 {};
00099 
00106 struct critical_section_tag
00107 
00108 {};
00109 
00110 #if 0
00111 
00122 struct recursive_critical_section_tag
00123 
00124 {};
00125 
00133 struct tryable_critical_section_tag
00134 
00135 {};
00136 #endif 
00137 
00147 template<   int R
00148         ,   int T
00149         >
00150 struct critical_section
00151     : public critical_section_tag
00152 {
00153     enum {  is_recursive    =   R       };
00154     enum {  is_tryable      =   T       };
00155 
00159     typedef ss_typename_type_k value_to_yesno_type<is_recursive>::type  is_recursive_type;
00160     typedef ss_typename_type_k value_to_yesno_type<is_tryable>::type    is_tryable_type;
00161 };
00162 
00163 
00164 #define STLSOFT_CRITICAL_SECTION_IS_RECURSIVE       (1)
00165 #define STLSOFT_CRITICAL_SECTION_ISNOT_RECURSIVE    (0)
00166 
00167 #define STLSOFT_CRITICAL_SECTION_IS_TRYABLE         (1)
00168 #define STLSOFT_CRITICAL_SECTION_ISNOT_TRYABLE      (0)
00169 
00170 
00171 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00172 
00173 typedef synchronisable_object_tag       synchronizable_object_tag;
00174 #endif 
00175 
00176 
00177 
00178 
00179 
00180 namespace concept_check
00181 {
00182     template <ss_typename_param_k S>
00183     void synch_conformance_synch_obj(S &s, synchronisable_object_tag const*)
00184     {
00185         s.handle();
00186 
00187         s.is_signalled();
00188 
00189         static_cast<int>(s.is_signalled()); 
00190     }
00191     template <ss_typename_param_k S>
00192     void synch_conformance_synch_obj(S &s, ...)
00193     {}
00194 
00195 
00196     template <ss_typename_param_k S>
00197     void synch_conformance_try_lock(S &s, yes_type)
00198     {
00199         if(s.try_lock())
00200         {
00201             s.unlock();
00202         }
00203     }
00204     template <ss_typename_param_k S>
00205     void synch_conformance_try_lock(S &s, no_type)
00206     {}
00207 
00208 
00209     template <ss_typename_param_k S>
00210     void synch_conformance_recursive_lock(S &s, yes_type)
00211     {
00212         s.lock();
00213         s.lock();
00214         s.unlock();
00215         s.unlock();
00216     }
00217     template <ss_typename_param_k S>
00218     void synch_conformance_recursive_lock(S &s, no_type)
00219     {}
00220 
00221     template <ss_typename_param_k S>
00222     void synch_conformance_lock(S &s, critical_section_tag const*)
00223     {
00224         s.lock();
00225         s.unlock();
00226 
00227         typedef ss_typename_type_k value_to_yesno_type<S::is_tryable>::type    is_tryable_type;
00228 
00229         synch_conformance_try_lock(s, is_tryable_type());
00230 
00231         typedef ss_typename_type_k value_to_yesno_type<S::is_recursive>::type  is_recursive_type;
00232 
00233         synch_conformance_recursive_lock(s, is_recursive_type());
00234     }
00235     template <ss_typename_param_k S>
00236     void synch_conformance_lock(S &s, ...)
00237     {}
00238 
00239 
00240 
00241     template <ss_typename_param_k S>
00242     void synch_conformance(S &s)
00243     {
00244         synch_conformance_synch_obj(s,&s);
00245         synch_conformance_lock(s, &s);
00246     }
00247 
00248 } 
00249 
00250 
00251 
00252 #ifndef _STLSOFT_NO_NAMESPACE
00253 } 
00254 #endif 
00255 
00256 
00257 
00258 #endif 
00259 
00260