00001
00002
00003
00004
00005 #include "ace/Global_Macros.h"
00006 #include "ace/OS_NS_Thread.h"
00007
00008 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00009
00010 #if defined (ACE_HAS_WCHAR)
00011
00012
00013 ACE_INLINE int
00014 ACE_SV_Semaphore_Simple::open (const wchar_t *name,
00015 short flags,
00016 int initial_value,
00017 u_short nsems,
00018 mode_t perms)
00019 {
00020 ACE_TRACE ("ACE_SV_Semaphore_Simple::open (wchar_t)");
00021 return this->open (ACE_Wide_To_Ascii (name).char_rep (),
00022 flags,
00023 initial_value,
00024 nsems,
00025 perms);
00026 }
00027 #endif
00028
00029 ACE_INLINE int
00030 ACE_SV_Semaphore_Simple::control (int cmd,
00031 semun arg,
00032 u_short n) const
00033 {
00034 ACE_TRACE ("ACE_SV_Semaphore_Simple::control");
00035 return this->internal_id_ == -1 ?
00036 -1 : ACE_OS::semctl (this->internal_id_, n, cmd, arg);
00037 }
00038
00039
00040
00041
00042 ACE_INLINE int
00043 ACE_SV_Semaphore_Simple::close (void)
00044 {
00045 ACE_TRACE ("ACE_SV_Semaphore_Simple::close");
00046 return this->init ();
00047 }
00048
00049
00050
00051 ACE_INLINE int
00052 ACE_SV_Semaphore_Simple::op (sembuf op_vec[], u_short n) const
00053 {
00054 ACE_TRACE ("ACE_SV_Semaphore_Simple::op");
00055 return this->internal_id_ == -1
00056 ? -1 : ACE_OS::semop (this->internal_id_, op_vec, n);
00057 }
00058
00059
00060
00061
00062
00063 ACE_INLINE int
00064 ACE_SV_Semaphore_Simple::acquire (u_short n, short flags) const
00065 {
00066 ACE_TRACE ("ACE_SV_Semaphore_Simple::acquire");
00067 return this->op (-1, n, flags);
00068 }
00069
00070 ACE_INLINE int
00071 ACE_SV_Semaphore_Simple::acquire_read (u_short n, short flags) const
00072 {
00073 ACE_TRACE ("ACE_SV_Semaphore_Simple::acquire_read");
00074 return this->acquire (n, flags);
00075 }
00076
00077 ACE_INLINE int
00078 ACE_SV_Semaphore_Simple::acquire_write (u_short n, short flags) const
00079 {
00080 ACE_TRACE ("ACE_SV_Semaphore_Simple::acquire_write");
00081 return this->acquire (n, flags);
00082 }
00083
00084
00085
00086 ACE_INLINE int
00087 ACE_SV_Semaphore_Simple::tryacquire (u_short n, short flags) const
00088 {
00089 ACE_TRACE ("ACE_SV_Semaphore_Simple::tryacquire");
00090 return this->op (-1, n, flags | IPC_NOWAIT);
00091 }
00092
00093
00094
00095 ACE_INLINE int
00096 ACE_SV_Semaphore_Simple::tryacquire_read (u_short n, short flags) const
00097 {
00098 ACE_TRACE ("ACE_SV_Semaphore_Simple::tryacquire_read");
00099 return this->tryacquire (n, flags);
00100 }
00101
00102
00103
00104 ACE_INLINE int
00105 ACE_SV_Semaphore_Simple::tryacquire_write (u_short n, short flags) const
00106 {
00107 ACE_TRACE ("ACE_SV_Semaphore_Simple::tryacquire_write");
00108 return this->tryacquire (n, flags);
00109 }
00110
00111
00112
00113
00114 ACE_INLINE int
00115 ACE_SV_Semaphore_Simple::release (u_short n, short flags) const
00116 {
00117 ACE_TRACE ("ACE_SV_Semaphore_Simple::release");
00118 return this->op (1, n, flags);
00119 }
00120
00121 ACE_INLINE int
00122 ACE_SV_Semaphore_Simple::get_id (void) const
00123 {
00124 ACE_TRACE ("ACE_SV_Semaphore_Simple::get_id");
00125 return this->internal_id_;
00126 }
00127
00128 ACE_END_VERSIONED_NAMESPACE_DECL