00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ACE_SV_SEMAPHORE_COMPLEX_H
00014 #define ACE_SV_SEMAPHORE_COMPLEX_H
00015 #include "ace/pre.h"
00016
00017 #include "ace/SV_Semaphore_Simple.h"
00018
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif
00022
00023 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class ACE_Export ACE_SV_Semaphore_Complex : private ACE_SV_Semaphore_Simple
00055 {
00056 public:
00057 enum
00058 {
00059 ACE_CREATE = IPC_CREAT,
00060 ACE_OPEN = 0
00061 };
00062
00063
00064 ACE_SV_Semaphore_Complex (void);
00065 ACE_SV_Semaphore_Complex (key_t key,
00066 short create = ACE_SV_Semaphore_Complex::ACE_CREATE,
00067 int initial_value = 1,
00068 u_short nsems = 1,
00069 mode_t perms = ACE_DEFAULT_FILE_PERMS);
00070 ACE_SV_Semaphore_Complex (const char *name,
00071 short create = ACE_SV_Semaphore_Complex::ACE_CREATE,
00072 int initial_value = 1,
00073 u_short nsems = 1,
00074 mode_t perms = ACE_DEFAULT_FILE_PERMS);
00075 ~ACE_SV_Semaphore_Complex (void);
00076
00077
00078
00079 int open (const char *name,
00080 short flags = ACE_SV_Semaphore_Simple::ACE_CREATE,
00081 int initial_value = 1,
00082 u_short nsems = 1,
00083 mode_t perms = ACE_DEFAULT_FILE_PERMS);
00084
00085
00086
00087 int open (key_t key,
00088 short flags = ACE_SV_Semaphore_Simple::ACE_CREATE,
00089 int initial_value = 1,
00090 u_short nsems = 1,
00091 mode_t perms = ACE_DEFAULT_FILE_PERMS);
00092
00093
00094
00095
00096
00097
00098
00099
00100 int close (void);
00101
00102
00103
00104
00105 int acquire (u_short n = 0, short flags = 0) const;
00106
00107
00108 int acquire_read (u_short n = 0, short flags = 0) const;
00109
00110
00111 int acquire_write (u_short n = 0, short flags = 0) const;
00112
00113
00114 int tryacquire (u_short n = 0, short flags = 0) const;
00115
00116
00117 int tryacquire_read (u_short n = 0, short flags = 0) const;
00118
00119
00120 int tryacquire_write (u_short n = 0, short flags = 0) const;
00121
00122
00123 int release (u_short n = 0, short flags = 0) const;
00124
00125
00126 int op (short val, u_short n = 0, short flags = 0) const;
00127 int op (sembuf op_vec[], u_short n) const;
00128
00129
00130 int control (int cmd, semun arg, u_short n = 0) const;
00131 int control (int cmd, int value = 0, u_short n = 0) const;
00132
00133
00134 using ACE_SV_Semaphore_Simple::get_id;
00135 using ACE_SV_Semaphore_Simple::remove;
00136
00137
00138 void dump (void) const;
00139
00140
00141 ACE_ALLOC_HOOK_DECLARE;
00142
00143 private:
00144 static const int BIGCOUNT_;
00145 static sembuf op_lock_[2];
00146 static sembuf op_endcreate_[2];
00147 static sembuf op_open_[1];
00148 static sembuf op_close_[3];
00149 static sembuf op_unlock_[1];
00150 };
00151
00152 ACE_END_VERSIONED_NAMESPACE_DECL
00153
00154 #if defined (__ACE_INLINE__)
00155 #include "ace/SV_Semaphore_Complex.inl"
00156 #endif
00157
00158 #include "ace/post.h"
00159 #endif