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 used to adapt libixp to any of the myriad threading systems it may be used with. 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.

The names of the functions should be fairly self-explanitory. Read/write locks should allow multiple readers and a single writer of a shared resource, but should not allow new readers while a writer is waitng for a lock. Mutexes should allow only one accessor at a time. Rendezvous points are similar to pthread condition types. errbuf should return a thread-local buffer or the size IXP_ERRMAX.

RELATED TO IxpRWLock…