Class: SysVIPC::Semaphore
- Inherits:
-
Object
- Object
- SysVIPC::Semaphore
- Defined in:
- lib/sysvipc.rb
Instance Method Summary collapse
-
#getall ⇒ Object
Return an Array containing the value of each semaphore in the set.
-
#getncnt ⇒ Object
(also: #ncnt)
Get the number of processes waiting for a semaphore to become non-zero.
-
#getpid ⇒ Object
(also: #pid)
Get the process ID of the last semaphore operation.
-
#getval(semnum) ⇒ Object
(also: #val)
Get the value of semaphore
semnum
. -
#getzcnt ⇒ Object
(also: #zcnt)
Get the number of processes waiting for a semaphore to become zero.
-
#ipc_rmid ⇒ Object
(also: #rm)
Remove.
-
#ipc_set(semid_ds) ⇒ Object
(also: #semid_ds=)
Set the Semid_ds object.
-
#ipc_stat ⇒ Object
(also: #semid_ds)
Return the Semid_ds object.
-
#op(array) ⇒ Object
Perform a set of semaphore operations.
-
#setall(values) ⇒ Object
Set each value in the semaphore set to the corresponding value in the Array
values
. -
#setval(semnum, val) ⇒ Object
Set the value of semaphore
semnum
toval
.
Instance Method Details
#getall ⇒ Object
Return an Array containing the value of each semaphore in the set. See semctl(2).
216 217 218 219 220 |
# File 'lib/sysvipc.rb', line 216 def getall res, array = semctl(@semid, 0, GETALL) check_result(res) array end |
#getncnt ⇒ Object Also known as: ncnt
Get the number of processes waiting for a semaphore to become non-zero. See semctl(2).
246 247 248 |
# File 'lib/sysvipc.rb', line 246 def getncnt semctl(@semid, 0, GETNCNT) end |
#getpid ⇒ Object Also known as: pid
Get the process ID of the last semaphore operation. See semctl(2).
238 239 240 |
# File 'lib/sysvipc.rb', line 238 def getpid semctl(@semid, 0, GETPID) end |
#getval(semnum) ⇒ Object Also known as: val
Get the value of semaphore semnum
. See semctl(2).
230 231 232 |
# File 'lib/sysvipc.rb', line 230 def getval(semnum) semctl(@semid, semnum, GETVAL) end |
#getzcnt ⇒ Object Also known as: zcnt
Get the number of processes waiting for a semaphore to become zero. See semctl(2).
254 255 256 |
# File 'lib/sysvipc.rb', line 254 def getzcnt semctl(@semid, 0, GETZCNT) end |
#ipc_rmid ⇒ Object Also known as: rm
Remove. See semctl(2).
281 282 283 |
# File 'lib/sysvipc.rb', line 281 def ipc_rmid check_result(semctl(@semid, 0, IPC_RMID)) end |
#ipc_set(semid_ds) ⇒ Object Also known as: semid_ds=
Set the Semid_ds object. See semctl(2).
270 271 272 273 274 275 276 |
# File 'lib/sysvipc.rb', line 270 def ipc_set(semid_ds) unless Semid_ds === semid_ds raise ArgumentError, "argument to ipc_set must be a Semid_ds" end check_result(semctl(@semid, 0, IPC_SET, semid_ds)) end |
#ipc_stat ⇒ Object Also known as: semid_ds
Return the Semid_ds object. See semctl(2).
261 262 263 264 265 |
# File 'lib/sysvipc.rb', line 261 def ipc_stat res, semid_ds = semctl(@semid, 0, IPC_STAT) check_result(res) semid_ds end |
#op(array) ⇒ Object
Perform a set of semaphore operations. The argument array
is an Array of Sembuf objects. See semop(2).
289 290 291 |
# File 'lib/sysvipc.rb', line 289 def op(array) check_result(semop(@semid, array, array.length)) end |
#setall(values) ⇒ Object
Set each value in the semaphore set to the corresponding value in the Array values
. See semctl(2).
205 206 207 208 209 210 211 |
# File 'lib/sysvipc.rb', line 205 def setall(values) if values.length > @nsems raise ArgumentError, "too many values(#{values.length} for semaphore set (#{@nsems})" end check_result(semctl(@semid, 0, SETALL, values)) end |
#setval(semnum, val) ⇒ Object
Set the value of semaphore semnum
to val
. See semctl(2).
224 225 226 |
# File 'lib/sysvipc.rb', line 224 def setval(semnum, val) check_result(semctl(@semid, semnum, SETVAL, val)) end |