<commit_before>﻿using System;
using System.Collections.Generic;

namespace CSGL.Vulkan {
    public class Fence : IDisposable, INative<VkFence> {
        VkFence fence;
        bool disposed = false;

        public VkFence Native {
            get {
                return fence;
            }
        }

        public VkResult Status {
            get {
                var result = Device.Commands.getFenceStatus(Device.Native, fence);
                if (!(result == VkResult.Success || result == VkResult.Timeout)) throw new FenceException(result, string.Format("Error getting status: {0}", result));
                return result;
            }
        }

        public Device Device { get; private set; }

        public Fence(Device device, VkFenceCreateFlags flags) {
            if (device == null) throw new ArgumentNullException(nameof(device));

            Device = device;

            CreateFence(flags);
        }

        void CreateFence(VkFenceCreateFlags flags) {
            VkFenceCreateInfo info = new VkFenceCreateInfo();
            info.sType = VkStructureType.FenceCreateInfo;
            info.flags = flags;

            var result = Device.Commands.createFence(Device.Native, ref info, Device.Instance.AllocationCallbacks, out fence);
            if (result != VkResult.Success) throw new FenceException(result, string.Format("Error creating fence: {0}", result));
        }

        public void Reset() {
            Reset(Device, new Fence[] { this });
        }

        public VkResult Wait(ulong timeout) {
            var result = Wait(Device, new Fence[] { this }, false, timeout);
            if (!(result == VkResult.Success || result == VkResult.Timeout)) throw new FenceException(result, string.Format("Error waiting on fence: {0}", result));
            return result;
        }

        public VkResult Wait() {
            return Wait(ulong.MaxValue);
        }

        public static void Reset(Device device, Fence[] fences) {
            if (device == null) throw new ArgumentNullException(nameof(device));
            if (fences == null) throw new ArgumentNullException(nameof(fences));

            unsafe {
                var fencesNative = stackalloc VkFence[fences.Length];
                Interop.Marshal<VkFence, Fence>(fences, fencesNative);

                var result = device.Commands.resetFences(device.Native, (uint)fences.Length, (IntPtr)fencesNative);
                if (result != VkResult.Success) throw new FenceException(result, string.Format("Error resetting fences: {0}", result));
            }
        }

        public static void Reset(Device device, List<Fence> fences) {
            if (device == null) throw new ArgumentNullException(nameof(device));
            if (fences == null) throw new ArgumentNullException(nameof(fences));

            unsafe {
                var fencesNative = stackalloc VkFence[fences.Count];
                Interop.Marshal<VkFence, Fence>(fences, fencesNative);

                var result = device.Commands.resetFences(device.Native, (uint)fences.Count, (IntPtr)fencesNative);
                if (result != VkResult.Success) throw new FenceException(result, string.Format("Error resetting fences: {0}", result));
            }
        }

        public static VkResult Wait(Device device, Fence[] fences, bool waitAll, ulong timeout) {
            if (device == null) throw new ArgumentNullException(nameof(device));
            if (fences == null) throw new ArgumentNullException(nameof(fences));

            unsafe {
                var fencesNative = stackalloc VkFence[fences.Length];
                Interop.Marshal<VkFence, Fence>(fences, fencesNative);

                uint waitAllNative = waitAll ? 1u : 0u;
                var result = device.Commands.waitFences(device.Native, (uint)fences.Length, (IntPtr)fencesNative, waitAllNative, timeout);
                if (!(result == VkResult.Success || result == VkResult.Timeout)) throw new FenceException(result, string.Format("Error waiting on fences: {0}", result));
                return result;
            }
        }

        public static VkResult Wait(Device device, List<Fence> fences, bool waitAll, ulong timeout) {
            if (device == null) throw new ArgumentNullException(nameof(device));
            if (fences == null) throw new ArgumentNullException(nameof(fences));

            unsafe {
                var fencesNative = stackalloc VkFence[fences.Count];
                Interop.Marshal<VkFence, Fence>(fences, fencesNative);

                uint waitAllNative = waitAll ? 1u : 0u;
                var result = device.Commands.waitFences(device.Native, (uint)fences.Count, (IntPtr)fencesNative, waitAllNative, timeout);
                if (!(result == VkResult.Success || result == VkResult.Timeout)) throw new FenceException(result, string.Format("Error waiting on fences: {0}", result));
                return result;
            }
        }

        public void Dispose() {
            Dispose(true);
            GC.SuppressFinalize(this);
        }<commit_msg>Remove overloads<commit_after>﻿using System;
using System.Collections.Generic;

namespace CSGL.Vulkan {
    public class Fence : IDisposable, INative<VkFence> {
        VkFence fence;
        bool disposed = false;

        public VkFence Native {
            get {
                return fence;
            }
        }

        public VkResult Status {
            get {
                var result = Device.Commands.getFenceStatus(Device.Native, fence);
                if (!(result == VkResult.Success || result == VkResult.Timeout)) throw new FenceException(result, string.Format("Error getting status: {0}", result));
                return result;
            }
        }

        public Device Device { get; private set; }

        public Fence(Device device, VkFenceCreateFlags flags) {
            if (device == null) throw new ArgumentNullException(nameof(device));

            Device = device;

            CreateFence(flags);
        }

        void CreateFence(VkFenceCreateFlags flags) {
            VkFenceCreateInfo info = new VkFenceCreateInfo();
            info.sType = VkStructureType.FenceCreateInfo;
            info.flags = flags;

            var result = Device.Commands.createFence(Device.Native, ref info, Device.Instance.AllocationCallbacks, out fence);
            if (result != VkResult.Success) throw new FenceException(result, string.Format("Error creating fence: {0}", result));
        }

        public void Reset() {
            Reset(Device, new Fence[] { this });
        }

        public VkResult Wait(ulong timeout) {
            var result = Wait(Device, new Fence[] { this }, false, timeout);
            if (!(result == VkResult.Success || result == VkResult.Timeout)) throw new FenceException(result, string.Format("Error waiting on fence: {0}", result));
            return result;
        }

        public VkResult Wait() {
            return Wait(ulong.MaxValue);
        }

        public static void Reset(Device device, IList<Fence> fences) {
            if (device == null) throw new ArgumentNullException(nameof(device));
            if (fences == null) throw new ArgumentNullException(nameof(fences));

            unsafe {
                var fencesNative = stackalloc VkFence[fences.Count];
                Interop.Marshal<VkFence, Fence>(fences, fencesNative);

                var result = device.Commands.resetFences(device.Native, (uint)fences.Count, (IntPtr)fencesNative);
                if (result != VkResult.Success) throw new FenceException(result, string.Format("Error resetting fences: {0}", result));
            }
        }

        public static VkResult Wait(Device device, IList<Fence> fences, bool waitAll, ulong timeout) {
            if (device == null) throw new ArgumentNullException(nameof(device));
            if (fences == null) throw new ArgumentNullException(nameof(fences));

            unsafe {
                var fencesNative = stackalloc VkFence[fences.Count];
                Interop.Marshal<VkFence, Fence>(fences, fencesNative);

                uint waitAllNative = waitAll ? 1u : 0u;
                var result = device.Commands.waitFences(device.Native, (uint)fences.Count, (IntPtr)fencesNative, waitAllNative, timeout);
                if (!(result == VkResult.Success || result == VkResult.Timeout)) throw new FenceException(result, string.Format("Error waiting on fences: {0}", result));
                return result;
            }
        }

        public void Dispose() {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
{'fraction_non_alphanumeric': 0.10324004180699106, 'fraction_numerical': 0.0020903495528974566, 'mean_word_length': 2.2522658610271904, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5482402', 'n_tokens_mistral': 2340, 'n_tokens_neox': 2260, 'n_words': 587}