tmux.h - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
tmux.h (1271B)
---
     1 #ifndef _MUX_H_
     2 #define _MUX_H_ 1
     3 #if defined(__cplusplus)
     4 extern "C" { 
     5 #endif
     6 
     7 AUTOLIB(mux)
     8 
     9 typedef struct Mux Mux;
    10 typedef struct Muxrpc Muxrpc;
    11 typedef struct Muxqueue Muxqueue;
    12 
    13 struct Muxrpc
    14 {
    15         Mux *mux;
    16         Muxrpc *next;
    17         Muxrpc *prev;
    18         Rendez r;
    19         uint tag;
    20         void *p;
    21         int waiting;
    22         int async;
    23 };
    24 
    25 struct Mux
    26 {
    27         uint mintag;        /* to be filled by client */
    28         uint maxtag;
    29         int (*send)(Mux*, void*);
    30         void *(*recv)(Mux*);
    31         int (*nbrecv)(Mux*, void**);
    32         int (*gettag)(Mux*, void*);
    33         int (*settag)(Mux*, void*, uint);
    34         void *aux;        /* for private use by client */
    35 
    36 /* private */
    37         QLock lk;        /* must be first for muxinit */
    38         QLock inlk;
    39         QLock outlk;
    40         Rendez tagrend;
    41         Rendez rpcfork;
    42         Muxqueue *readq;
    43         Muxqueue *writeq;
    44         uint nwait;
    45         uint mwait;
    46         uint freetag;
    47         Muxrpc **wait;
    48         Muxrpc *muxer;
    49         Muxrpc sleep;
    50 };
    51 
    52 void        muxinit(Mux*);
    53 void*        muxrpc(Mux*, void*);
    54 void        muxprocs(Mux*);
    55 Muxrpc*        muxrpcstart(Mux*, void*);
    56 int        muxrpccanfinish(Muxrpc*, void**);
    57 
    58 /* private */
    59 int        _muxsend(Mux*, void*);
    60 int        _muxrecv(Mux*, int, void**);
    61 void        _muxsendproc(void*);
    62 void        _muxrecvproc(void*);
    63 Muxqueue *_muxqalloc(void);
    64 int _muxqsend(Muxqueue*, void*);
    65 void *_muxqrecv(Muxqueue*);
    66 void _muxqhangup(Muxqueue*);
    67 int _muxnbqrecv(Muxqueue*, void**);
    68 
    69 #if defined(__cplusplus)
    70 }
    71 #endif
    72 #endif