vibe.d beta banner
get vibe.d
0.10.1

Asynchronous I/O that doesn’t get in your way, written in D

Struct SemaphoreStream

Limits the number concurrent blocking operations using a semaphore.

struct SemaphoreStream(Stream, Semaphore, LockArgs...) ;

This stream can be used to wrap any type of stream in order to limit the amount of concurrent I/O operations across all streams that use the same semaphore. The main use for this is avoiding high concurrency overhead on I/O devices with bad random access performance, such as spinning hard disks.

Constructors

NameDescription
this (stream, semaphore, lock_args)

Fields

NameTypeDescription
m_lockArgs LockArgs
m_semaphore Semaphore
m_stream Stream

Properties

NameTypeDescription
connected[get] bool
dataAvailableForRead[get] bool
empty[get] bool
isOpen[get] bool
leastSize[get] ulong
readable[get] bool
size[get] ulong
writable[get] bool

Methods

NameDescription
close ()
close ()
finalize ()
flush ()
lock ()
peek ()
read (dst, mode)
read (dst)
seek (offset)
tell ()
truncate (size)
waitForData (timeout)
write (bytes, mode)
write (bytes)
write (bytes)

See also

createSemaphoreStream

Authors

Sönke Ludwig

Copyright

© 2023 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.