/// <summary>Initializes a new instance of the <see cref="DisposableMutex" /> struct.</summary> /// <param name="mutex">The mutex on which a lock should be acquired.</param> /// <param name="isExternallySynchronized"><c>false</c> if a lock on <paramref name="mutex" /> should be acquired; otherwise, <c>true</c>.</param> public DisposableMutex(ValueMutex mutex, bool isExternallySynchronized) { Assert(!mutex.IsNull); if (!isExternallySynchronized) { mutex.AcquireLock(); _mutex = mutex; } else { _mutex = default; } }
internal GraphicsAdapter(GraphicsService service, IDXGIAdapter1 *dxgiAdapter) : base(service) { dxgiAdapter = GetLatestDxgiAdapter(dxgiAdapter, out _dxgiAdapterVersion); _dxgiAdapter.Attach(dxgiAdapter); DXGI_ADAPTER_DESC1 dxgiAdapterDesc; ThrowExternalExceptionIfFailed(dxgiAdapter->GetDesc1(&dxgiAdapterDesc)); _description = GetUtf16Span(dxgiAdapterDesc.Description, 128).GetString() ?? string.Empty; _pciDeviceId = dxgiAdapterDesc.DeviceId; _pciVendorId = dxgiAdapterDesc.VendorId; SetName(_description); _devices = new ValueList <GraphicsDevice>(); _devicesMutex = new ValueMutex(); }
/// <summary>Removes the first occurence of an item from the pool.</summary> /// <param name="item">The item to remove from the pool.</param> /// <param name="mutex">The mutex to use when removing an item from the pool.</param> /// <returns><c>true</c> if <paramref name="item" /> was removed from the pool; otherwise, <c>false</c>.</returns> public bool Remove(T item, ValueMutex mutex) { using var disposableMutex = new DisposableMutex(mutex, isExternallySynchronized: false); return(Remove(item)); }
internal GraphicsRenderCommandQueue(GraphicsDevice device) : base(device, GraphicsContextKind.Render) { _contexts = new ValuePool <GraphicsRenderContext>(); _contextsMutex = new ValueMutex(); }