IOCallback(3I)
π IOCallback β bestie edition π
IOCallback(3I) Β· from the InterViews Reference Manual Β· yes we're reading a whole manual together, it's giving study date π
β¨ NAME β¨
IOCallback β the generic callback class for readers, writers, or I/O exception handlers π¦
Like, it's the plug anything in here class. Reader energy, writer energy, exception-handler energy, all of it. Slay.
πΈ SYNOPSIS πΈ
#include <Dispatch/iocallback.h>
That's it. That's the whole vibe check. One include and you're in. π
π«Ά DESCRIPTION π«Ά
Okay so listen, bestie β the macros in iocallback.h exist purely for convenience, and what they do is let you define an iohandler that literally does nothing except call some arbitrary object's member function. That's it. That's the whole job. No cap. π§
Which means the actual code β the part that reads data from a file descriptor, writes data to a file descriptor, handles an I/O exception on a file descriptor, or handles a timer's expiration β gets to live in any arbitrary class you want instead of being trapped inside the iohandler. Main character energy for your own classes, honestly. π
β MACROS β
declareIOCallback(T)β declares aniocallbacktype for the given class typeT. Announce it, bestie. π£implementIOCallback(T)β emits code at this point to implement theiocallback's member functions. This is where you actually make it real. πͺIOCallback(T)* instance = new IOCallback(T)(...)β defines an instance of theiocallbacktype for the given class typeT. New instance, who dis. β¨
π CONSTRUCTORS π
First, the typedefs. These are the shapes of the member functions you'll be handing over:
typedef int T::IOReady(T)(int fd)
typedef void T::IOTimer(T)(long sec, long usec)
And now the constructors themselves:
IOCallback(T)(T*, IOReady(T)* in, IOReady(T)* out = nil, IOReady(T)* ex
= nil)
IOCallback(T)(T*, IOTimer(T)*, IOReady(T)* in = nil, IOReady(T)* out =
nil, IOReady(T)* ex = nil)
What they do: they construct an instance of the iocallback type that will call the given member functions of the given class type T's instance. π
And no, bestie, you do not have to use theIOReady(T)orIOTimer(T)macros. All you actually have to do is pass the address of aTmember function β like&T::inputReady. That's it. That's the whole trick. iykyk π
π SEE ALSO π
Dispatcher(3I)IOHandler(3I)
Go read those next, you know you want to. πΈ
InterViews Β· 21 December 1990 β mwah, thanks for reading, this page came straight from the InterViews reference manual and it's lowkey iconic for being this old and still this useful π π¦β¨ periodt.
π¦ where this page comes from
- debian bookworm: ivtools-dev 2.0.11d.a1-1+b4
- debian trixie: ivtools-dev 2.0.11d.a1-3+b4
- ubuntu jammy: ivtools-dev 2.0.11d.a1-1build1
- ubuntu noble: ivtools-dev 2.0.11d.a1-3build1
- ubuntu questing: ivtools-dev 2.0.11d.a1-3build7
- ubuntu resolute: ivtools-dev 2.0.11d.a1-3build9
- ubuntu stonking: ivtools-dev 2.1.1+git.2025.07.26.a1-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms