[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / SV_Semaphore_Simple.inl
blob777e85fbf43fceb21ed25423af1c4a1fa9027333
1 // -*- C++ -*-
2 //
3 // $Id: SV_Semaphore_Simple.inl 80826 2008-03-04 14:51:23Z wotte $
5 #include "ace/Global_Macros.h"
6 #include "ace/OS_NS_Thread.h"
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 #if defined (ACE_HAS_WCHAR)
11 // Semaphores don't offer wide-char names, so convert the name and forward
12 // to the narrow-char open().
13 ACE_INLINE int
14 ACE_SV_Semaphore_Simple::open (const wchar_t *name,
15                                short flags,
16                                int initial_value,
17                                u_short nsems,
18                                mode_t perms)
20   ACE_TRACE ("ACE_SV_Semaphore_Simple::open (wchar_t)");
21   return this->open (ACE_Wide_To_Ascii (name).char_rep (),
22                      flags,
23                      initial_value,
24                      nsems,
25                      perms);
27 #endif /* ACE_HAS_WCHAR */
29 ACE_INLINE int
30 ACE_SV_Semaphore_Simple::control (int cmd,
31                                   semun arg,
32                                   u_short n) const
34   ACE_TRACE ("ACE_SV_Semaphore_Simple::control");
35   return this->internal_id_ == -1 ?
36     -1 : ACE_OS::semctl (this->internal_id_, n, cmd, arg);
39 // Close a ACE_SV_Semaphore, marking it as invalid for subsequent
40 // operations...
42 ACE_INLINE int
43 ACE_SV_Semaphore_Simple::close (void)
45   ACE_TRACE ("ACE_SV_Semaphore_Simple::close");
46   return this->init ();
49 // General ACE_SV_Semaphore operation on an array of SV_Semaphores.
51 ACE_INLINE int
52 ACE_SV_Semaphore_Simple::op (sembuf op_vec[], u_short n) const
54   ACE_TRACE ("ACE_SV_Semaphore_Simple::op");
55   return this->internal_id_ == -1
56     ? -1 : ACE_OS::semop (this->internal_id_, op_vec, n);
59 // Wait until a ACE_SV_Semaphore's value is greater than 0, the
60 // decrement it by 1 and return. Dijkstra's P operation, Tannenbaums
61 // DOWN operation.
63 ACE_INLINE int
64 ACE_SV_Semaphore_Simple::acquire (u_short n, short flags) const
66   ACE_TRACE ("ACE_SV_Semaphore_Simple::acquire");
67   return this->op (-1, n, flags);
70 ACE_INLINE int
71 ACE_SV_Semaphore_Simple::acquire_read (u_short n, short flags) const
73   ACE_TRACE ("ACE_SV_Semaphore_Simple::acquire_read");
74   return this->acquire (n, flags);
77 ACE_INLINE int
78 ACE_SV_Semaphore_Simple::acquire_write (u_short n, short flags) const
80   ACE_TRACE ("ACE_SV_Semaphore_Simple::acquire_write");
81   return this->acquire (n, flags);
84 // Non-blocking version of acquire().
86 ACE_INLINE int
87 ACE_SV_Semaphore_Simple::tryacquire (u_short n, short flags) const
89   ACE_TRACE ("ACE_SV_Semaphore_Simple::tryacquire");
90   return this->op (-1, n, flags | IPC_NOWAIT);
93 // Non-blocking version of acquire().
95 ACE_INLINE int
96 ACE_SV_Semaphore_Simple::tryacquire_read (u_short n, short flags) const
98   ACE_TRACE ("ACE_SV_Semaphore_Simple::tryacquire_read");
99   return this->tryacquire (n, flags);
102 // Non-blocking version of acquire().
104 ACE_INLINE int
105 ACE_SV_Semaphore_Simple::tryacquire_write (u_short n, short flags) const
107   ACE_TRACE ("ACE_SV_Semaphore_Simple::tryacquire_write");
108   return this->tryacquire (n, flags);
111 // Increment ACE_SV_Semaphore by one. Dijkstra's V operation,
112 // Tannenbaums UP operation.
114 ACE_INLINE int
115 ACE_SV_Semaphore_Simple::release (u_short n, short flags) const
117   ACE_TRACE ("ACE_SV_Semaphore_Simple::release");
118   return this->op (1, n, flags);
121 ACE_INLINE int
122 ACE_SV_Semaphore_Simple::get_id (void) const
124   ACE_TRACE ("ACE_SV_Semaphore_Simple::get_id");
125   return this->internal_id_;
128 ACE_END_VERSIONED_NAMESPACE_DECL