IXPTHREAD(3)

πŸ“¦ version 0-unstable-2022-04, in nixos 26.05, nixpkgs unstable

πŸ’… NAME

Welcome to IxpThread(3), bestie β€” it's from the Library Functions Manual, and it's the libixp page for IxpThread, IxpMutex, IxpRWLock, IxpRendez, and the global ixp_thread. Basically: the whole threading-adapter friend group. πŸ’–

✨ SYNOPSIS

#include <ixp.h>

typedef struct IxpThread IxpThread;
struct IxpThread {
        /* Read/write lock */
        int     (*initrwlock)(IxpRWLock*);
        void    (*rlock)(IxpRWLock*);
        int     (*canrlock)(IxpRWLock*);
        void    (*runlock)(IxpRWLock*);
        void    (*wlock)(IxpRWLock*);
        int     (*canwlock)(IxpRWLock*);
        void    (*wunlock)(IxpRWLock*);
        void    (*rwdestroy)(IxpRWLock*);
        /* Mutex */
        int     (*initmutex)(IxpMutex*);
        void    (*lock)(IxpMutex*);
        int     (*canlock)(IxpMutex*);
        void    (*unlock)(IxpMutex*);
        void    (*mdestroy)(IxpMutex*);
        /* Rendezvous point */
        int     (*initrendez)(IxpRendez*);
        void    (*sleep)(IxpRendez*);
        int     (*wake)(IxpRendez*);
        int     (*wakeall)(IxpRendez*);
        void    (*rdestroy)(IxpRendez*);
        /* Other */
        char*   (*errbuf)(void);
        ssize_t (*read)(int, void*, size_t);
        ssize_t (*write)(int, const void*, size_t);
        int     (*select)(int, fd_set*, fd_set*, fd_set*, struct timeval*);
}

typedef struct IxpMutex IxpMutex;
struct IxpMutex {
        void*   aux;
}

typedef struct IxpRWLock IxpRWLock;
struct IxpRWLock {
        void*   aux;
}

typedef struct IxpRendez IxpRendez;
struct IxpRendez {
        IxpMutex*       mutex;
        void*   aux;
}

IxpThread*       ixp_thread;

🫢 DESCRIPTION

The IxpThread structure is how libixp adapts to any of the myriad threading systems it may be used with. It's giving "universal adapter" energy, and honestly? Obsessed. πŸ’«

Before any other of libixp's functions is called, ixp_thread may be set to a structure filled with implementations of various locking primitives, along with primitive IO functions which may perform context switches until data is available. Think of it as your libixp starter pack for whatever threading world you're living in. πŸŽ€

The names of the functions should be fairly self-explanitory β€” like, you can clock what they do. But here's the vibe check anyway:

  • Read/write locks β€” bestie, these should allow multiple readers and a single writer of a shared resource, but they should not allow new readers while a writer is waiting for a lock. That's the rule. No cap. πŸ”₯
  • Mutexes β€” only one accessor at a time. One. At. A. Time. πŸ’…
  • Rendezvous points β€” similar to pthread condition types. Cute, right? πŸ¦‹
  • errbuf β€” should return a thread-local buffer or the size IXP_ERRMAX. Periodt. ✨

🌈 SEE ALSO

Go read these too, bestie, they're literally right there:


Source and date check, because we keep the receipts: this is from the libixp Manual, dated 2012 Dec. Mwah πŸ’‹πŸ«ΆπŸ’–

πŸ“¦ where this page comes from