private void Configure(IntPtr aioPtr) { PrivateOptions.SetSetters( x => __SetTimeoutDurationMilliseconds(_aioPtr, x) ); // TODO: TBD: perhaps we can run direct through the C calling conventions. _free = () => __Free(aioPtr); _wait = () => __Wait(aioPtr); _stop = () => __Stop(aioPtr); _cancel = () => __Cancel(aioPtr); _getResult = () => __GetResult(aioPtr); _getMessagePtr = () => __GetMessagePtr(aioPtr); _setMessagePtr = msgPtr => __SetMessagePtr(aioPtr, msgPtr); }
private void Configure(uint pid) { _closer = () => __Close(pid); _reset = ptr => __SetPipe(ptr, pid); var opt = PrivateOptions; opt.SetGetters( (string name, ref int value) => __GetOptInt32(pid, name, ref value) , (string name, ref ulong value) => __GetOptUInt64(pid, name, ref value) , (string name, StringBuilder value, ref ulong length) => __GetOptStringBuilder( pid, name, value, ref length) , (string name, ref int value) => __GetOptDurationMilliseconds(pid, name, ref value) ); }
protected internal virtual void InvokeWithDefaultErrorHandling(InvocationWithResultDelegate <int> caller , params ErrorCode[] notOneOf) { var errnum = caller(); if (!notOneOf.Any()) { notOneOf = new[] { None }; } if (notOneOf.Any(x => errnum == (int)x)) { return; } // TODO: TBD: do something with the result... // TODO: TBD: introduce an appropriately named exception throw new NanoException(errnum); }
protected internal TResult InvokeWithResult <TResult>(InvocationWithResultDelegate <IntPtr, TResult> caller, IntPtr ptr) { return(caller(ptr)); }
protected internal virtual void InvokeWithDefaultErrorHandling(InvocationWithResultDelegate <IntPtr, int> caller , IntPtr ptr, params ErrorCode[] notOneOf) { InvokeWithDefaultErrorHandling <IntPtr>(caller, ptr, notOneOf); }
// TODO: TBD: will need to consider the "throw if one of" scenario... protected internal virtual void InvokeWithDefaultErrorHandling <T>(InvocationWithResultDelegate <T, int> caller , T ptr, params ErrorCode[] notOneOf) { InvokeWithDefaultErrorHandling(() => caller(ptr), notOneOf); }
protected internal virtual TResult InvokeWithResult <T, TResult>(InvocationWithResultDelegate <T, TResult> caller, T ptr) { var result = caller(ptr); return(result); }
internal void InvokeWithDefaultErrorHandling(InvocationWithResultDelegate <IntPtr, int> caller) { // Make sure that the Message we allocate is the same one we pass for Invocation. Allocate(ref _msgPtr); base.InvokeWithDefaultErrorHandling(caller, _msgPtr); }
internal TResult InvokeWithResult <TResult>(InvocationWithResultDelegate <IntPtr, TResult> caller) { // Ditto Message ptr alignment. Allocate(ref _msgPtr); return(InvokeWithResult(caller, _msgPtr)); }