mirror of
https://github.com/RPCS3/discord-bot.git
synced 2024-11-26 19:50:36 +00:00
use new Lock type for explicit synchronization
This commit is contained in:
parent
d4e78d1b1b
commit
a9ff00f80e
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CompatBot.Commands.Attributes;
|
||||
using CompatBot.Database;
|
||||
@ -72,7 +73,7 @@ namespace CompatBot.EventHandlers
|
||||
[GeneratedRegex(@"\b((?<kot>kot(to)?)|(?<doggo>doggo|jarves))\b", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture)]
|
||||
private static partial Regex Paws();
|
||||
private static readonly Random Rng = new();
|
||||
private static readonly object TheDoor = new();
|
||||
private static readonly Lock TheDoor = new();
|
||||
|
||||
public static DiscordEmoji RandomNegativeReaction { get { lock (TheDoor) return SadReactions[Rng.Next(SadReactions.Length)]; } }
|
||||
public static DiscordEmoji RandomPositiveReaction { get { lock (TheDoor) return ThankYouReactions[Rng.Next(ThankYouReactions.Length)]; } }
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace CompatBot.Utils;
|
||||
|
||||
@ -14,7 +15,7 @@ internal class BufferCopyStream : Stream, IDisposable
|
||||
private readonly byte[] writeBuf;
|
||||
private readonly byte[] readBuf;
|
||||
private int bufStart, bufLength;
|
||||
private readonly object sync = new();
|
||||
private readonly Lock sync = new();
|
||||
private bool disposed;
|
||||
|
||||
public BufferCopyStream(Stream? baseStream, int bufferSize = 4096)
|
||||
|
@ -2,13 +2,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace CompatBot.Utils;
|
||||
|
||||
internal class FixedLengthBuffer<TKey, TValue>: IList<TValue>
|
||||
where TKey: notnull
|
||||
{
|
||||
internal readonly object SyncObj = new();
|
||||
internal readonly Lock SyncObj = new();
|
||||
|
||||
public FixedLengthBuffer(Func<TValue, TKey> keyGenerator)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user