- Added asynchronous IO code from ANSTO
- Added new ACT protocol - Extended sicshdbadapter to cover counters and status to put the status into Hipadaba - Fixes to napi5.c - Exe now supports hdbrun which allows to write output for a buffer into hdb node.
This commit is contained in:
61
asyncprotocol.h
Normal file
61
asyncprotocol.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef ASYNCPROTOCOL
|
||||
#define ASYNCPROTOCOL
|
||||
|
||||
typedef struct __AsyncUnit AsyncUnit, *pAsyncUnit;
|
||||
|
||||
typedef struct __async_txn AsyncTxn, *pAsyncTxn;
|
||||
typedef int (*AsyncTxnHandler)(pAsyncTxn pTxn);
|
||||
|
||||
typedef struct __async_protocol AsyncProtocol, *pAsyncProtocol;
|
||||
|
||||
pAsyncProtocol AsyncProtocolCreate(SicsInterp *pSics, const char* protocolName,
|
||||
ObjectFunc pFunc, KillFunc pKFunc);
|
||||
|
||||
int AsyncProtocolAction(SConnection *pCon, SicsInterp *pSics,
|
||||
void *pData, int argc, char *argv[]);
|
||||
|
||||
int AsyncProtocolFactory(SConnection *pCon, SicsInterp *pSics,
|
||||
void *pData, int argc, char *argv[]);
|
||||
|
||||
typedef enum {
|
||||
ATX_NULL=0,
|
||||
ATX_TIMEOUT=-1,
|
||||
ATX_ACTIVE=1,
|
||||
ATX_COMPLETE=2
|
||||
} ATX_STATUS;
|
||||
|
||||
struct __async_txn {
|
||||
pAsyncUnit unit; /**< unit that transaction is associated with */
|
||||
int txn_state; /**< protocol handler transaction parse state */
|
||||
ATX_STATUS txn_status; /**< status of the transaction OK, Error, ... */
|
||||
int txn_timeout; /**< transaction timeout in milliseconds */
|
||||
char* out_buf; /**< output buffer for sendCommand */
|
||||
int out_len; /**< length of data to be sent */
|
||||
int out_idx; /**< index of next character to transmit */
|
||||
char* inp_buf; /**< input buffer for transaction response */
|
||||
int inp_len; /**< length of input buffer */
|
||||
int inp_idx; /**< index of next character (number already received) */
|
||||
AsyncTxnHandler handleResponse; /**< Txn response handler of command sender */
|
||||
void* cntx; /**< opaque context used by command sender */
|
||||
/* The cntx field may be used by protocol handler from sendCommand
|
||||
* as long as it is restored when response is complete
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
* The async protocol interface virtual function table
|
||||
*/
|
||||
struct __async_protocol {
|
||||
pObjectDescriptor pDes;
|
||||
char* protocolName;
|
||||
char *sendTerminator;
|
||||
char *replyTerminator;
|
||||
void* privateData;
|
||||
int (* sendCommand)(pAsyncProtocol p, pAsyncTxn txn);
|
||||
int (* handleInput)(pAsyncProtocol p, pAsyncTxn txn, int ch);
|
||||
int (* handleEvent)(pAsyncProtocol p, pAsyncTxn txn, int event);
|
||||
int (* prepareTxn)(pAsyncProtocol p, pAsyncTxn txn, const char* cmd, int cmd_len, int rsp_len);
|
||||
void (* killPrivate)(pAsyncProtocol p);
|
||||
};
|
||||
|
||||
#endif /* ASYNCPROTOCOL */
|
||||
Reference in New Issue
Block a user