Beispiel #1
0
        public TPoolItem AllocatePure()
        {
            _freeSize--;
            var obj = EntityPtr.ToInstanceWithOffset <TPoolItem>(_freeObjects[_freeSize]);

            _ctor.Invoke(obj, new object[] { 123 });
            return(obj);
        }
Beispiel #2
0
    /// <summary>
    /// Wait for an object to hit the shared memory and then deserialize it.
    /// </summary>
    /// <returns>object passed</returns>
    public TransferItemType ReceiveObject()
    {
        // Wait on the mutex for an object to be queued by the sender.
        semaphoreRecieve.WaitOne();

        // Read out the bytes for the object.
        return(EntityPtr.ToInstanceWithOffset <TransferItemType>((IntPtr)((int)ptrToMemory)));
    }
Beispiel #3
0
        public TPoolItem Allocate()
        {
            _freeSize--;
            var obj = _freeObjects[_freeSize];

            Stub.Construct(obj, 123);
            return(EntityPtr.ToInstanceWithOffset <TPoolItem>(obj));
        }
Beispiel #4
0
    /// <summary>
    /// Send a serializable object through the shared memory
    /// and wait for it to be picked up.
    /// </summary>
    /// <param name="transferObject"> </param>
    public TransferItemType ShareObject(TransferItemType transferObject)
    {
        try
        {
            var ptr = EntityPtr.ToPointerWithOffset(transferObject);

            // Write out how long this object is.
            var typesize = transferObject.SizeOf();

            // Write out the bytes.
            WinApi.memcpy((IntPtr)((int)ptrToMemory), ptr, typesize);

            return(EntityPtr.ToInstanceWithOffset <TransferItemType>((IntPtr)((int)ptrToMemory)));
        }
        finally
        {
            // Signal the other process using the mutex to tell it
            // to do receive processing.
            semaphoreRecieve.Release();
        }
    }