Commit 17e82256 authored by Jeremy Meng's avatar Jeremy Meng

Use DNXCORE50 constant instead of NETCORE. Socket is only supported on dnxcore.

parent d694d922
......@@ -239,7 +239,7 @@ public void MassiveBulkOpsAsync(bool preserveOrder, bool withContinuation)
Action<Task> nonTrivial = delegate
{
#if !NETCORE
#if !DNXCORE50
Thread.SpinWait(5);
#else
var spinWait = new SpinWait();
......@@ -488,14 +488,17 @@ public void MassiveBulkOpsSyncOldStyle(ResultCompletionMode completionMode, int
}
#endif
//TODO: Ignore("dnxcore crash")
#if !DNXCORE50
[Test]
[TestCase(true, 1)]
[TestCase(false, 1)]
[TestCase(true, 5)]
[TestCase(false, 5)]
#endif
public void MassiveBulkOpsFireAndForget(bool preserveOrder, int threads)
{
using (var muxer = Create())
using (var muxer = Create(syncTimeout:20000))
{
muxer.PreserveAsyncOrder = preserveOrder;
#if DEBUG
......
......@@ -20,7 +20,7 @@ public class Cluster : TestBase
protected override string GetConfiguration()
{
var server = ClusterIp;
#if !NETCORE
#if !DNXCORE50
if (string.Equals(Environment.MachineName, "MARC-LAPTOP", StringComparison.InvariantCultureIgnoreCase))
#else
if (string.Equals(Environment.GetEnvironmentVariable("COMPUTERNAME"), "MARC-LAPTOP", StringComparison.OrdinalIgnoreCase))
......
......@@ -144,7 +144,7 @@ public void ReadConfig()
var all = conn.ConfigGet();
Assert.IsTrue(all.Length > 0, "any");
#if !NETCORE
#if !DNXCORE50
var pairs = all.ToDictionary(x => (string)x.Key, x => (string)x.Value, StringComparer.InvariantCultureIgnoreCase);
#else
var pairs = all.ToDictionary(x => (string)x.Key, x => (string)x.Value, StringComparer.OrdinalIgnoreCase);
......
......@@ -9,7 +9,7 @@ public class SO25567566 : TestBase
{
protected override string GetConfiguration()
{
return "127.0.0.1";
return "127.0.0.1:6379";
}
[Test]
public async void Execute()
......
......@@ -150,7 +150,7 @@ public void CheckSyncAsyncMethodsMatch(Type from, Type to)
var pFrom = method.GetParameters();
Type[] args = pFrom.Select(x => x.ParameterType).ToArray();
Assert.AreEqual(typeof(CommandFlags), args.Last());
#if !NETCORE
#if !DNXCORE50
var found = to.GetMethod(huntName, flags, null, method.CallingConvention, args, null);
#else
var found = to.GetMethods(flags)
......@@ -176,14 +176,14 @@ void CheckMethod(MethodInfo method, bool isAsync)
{
#if DEBUG
#if !NETCORE
#if !DNXCORE50
bool ignorePrefix = ignoreType != null && Attribute.IsDefined(method, ignoreType);
#else
bool ignorePrefix = ignoreType != null && method.IsDefined(ignoreType);
#endif
if (ignorePrefix)
{
#if !NETCORE
#if !DNXCORE50
Attribute attrib = Attribute.GetCustomAttribute(method, ignoreType);
#else
Attribute attrib = method.GetCustomAttribute(ignoreType);
......@@ -228,7 +228,7 @@ void CheckName(MemberInfo member, bool isAsync)
public static class ReflectionExtensions
{
#if !NETCORE
#if !DNXCORE50
public static Type GetTypeInfo(this Type type)
{
return type;
......
......@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
#if NETCORE
#if DNXCORE50
using System.Reflection;
#endif
using System.Threading.Tasks;
......
......@@ -417,7 +417,7 @@ internal static class VolatileWrapper
{
public static int Read(ref int location)
{
#if !NETCORE
#if !DNXCORE50
return Thread.VolatileRead(ref location);
#else
return Volatile.Read(ref location);
......
......@@ -285,7 +285,7 @@ protected static TimeSpan RunConcurrent(Action work, int threads, int timeout =
}
if (!allDone.WaitOne(timeout))
{
#if !NETCORE
#if !DNXCORE50
for (int i = 0; i < threads; i++)
{
var thd = threadArr[i];
......
......@@ -21,7 +21,6 @@
"frameworks": {
"dnxcore50": {
"compilationOptions": {
"define": [ "NETCORE" ],
"warningsAsErrors": false
},
"dependencies": {
......
......@@ -10,7 +10,7 @@ internal static class VolatileWrapper
{
public static int Read(ref int location)
{
#if !NETCORE
#if !DNXCORE50
return System.Threading.Thread.VolatileRead(ref location);
#else
return System.Threading.Volatile.Read(ref location);
......@@ -19,7 +19,7 @@ public static int Read(ref int location)
public static void Write(ref int address, int value)
{
#if !NETCORE
#if !DNXCORE50
System.Threading.Thread.VolatileWrite(ref address, value);
#else
System.Threading.Volatile.Write(ref address, value);
......
......@@ -30,7 +30,7 @@ public enum Proxy
/// The options relevant to a set of redis connections
/// </summary>
public sealed class ConfigurationOptions
#if !NETCORE
#if !DNXCORE50
: ICloneable
#endif
{
......@@ -143,7 +143,7 @@ public static string TryNormalize(string value)
/// Indicates whether the connection should be encrypted
/// </summary>
[Obsolete("Please use .Ssl instead of .UseSsl"),
#if !NETCORE
#if !DNXCORE50
Browsable(false),
#endif
EditorBrowsable(EditorBrowsableState.Never)]
......@@ -470,7 +470,7 @@ static void Append(StringBuilder sb, string prefix, object value)
}
}
#if !NETCORE
#if !DNXCORE50
static bool IsOption(string option, string prefix)
{
return option.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase);
......@@ -492,7 +492,7 @@ void Clear()
SocketManager = null;
}
#if !NETCORE
#if !DNXCORE50
object ICloneable.Clone() { return Clone(); }
#endif
......
......@@ -561,7 +561,7 @@ private static bool WaitAllIgnoreErrors(Task[] tasks, int timeout)
return false;
}
#if !NETCORE
#if !DNXCORE50
private void LogLockedWithThreadPoolStats(TextWriter log, string message, out int busyWorkerCount)
{
busyWorkerCount = 0;
......@@ -603,7 +603,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
}
var watch = Stopwatch.StartNew();
#if !NETCORE
#if !DNXCORE50
int busyWorkerCount;
LogLockedWithThreadPoolStats(log, "Awaiting task completion", out busyWorkerCount);
#endif
......@@ -613,7 +613,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
var remaining = timeoutMilliseconds - checked((int)watch.ElapsedMilliseconds);
if (remaining <= 0)
{
#if !NETCORE
#if !DNXCORE50
LogLockedWithThreadPoolStats(log, "Timeout before awaiting for tasks", out busyWorkerCount);
#endif
return false;
......@@ -627,7 +627,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
var any = Task.WhenAny(allTasks, Task.Delay(remaining)).ObserveErrors();
#endif
bool all = await any.ForAwait() == allTasks;
#if !NETCORE
#if !DNXCORE50
LogLockedWithThreadPoolStats(log, all ? "All tasks completed cleanly" : "Not all tasks completed cleanly", out busyWorkerCount);
#endif
return all;
......@@ -645,7 +645,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
var remaining = timeoutMilliseconds - checked((int)watch.ElapsedMilliseconds);
if (remaining <= 0)
{
#if !NETCORE
#if !DNXCORE50
LogLockedWithThreadPoolStats(log, "Timeout awaiting tasks", out busyWorkerCount);
#endif
return false;
......@@ -663,7 +663,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
{ }
}
}
#if !NETCORE
#if !DNXCORE50
LogLockedWithThreadPoolStats(log, "Finished awaiting tasks", out busyWorkerCount);
#endif
return false;
......@@ -1887,7 +1887,7 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
else
{
int inst, qu, qs, qc, wr, wq, @in, ar;
#if !__MonoCS__ && !NETCORE
#if !__MonoCS__ && !DNXCORE50
var mgrState = socketManager.State;
var lastError = socketManager.LastErrorTimeRelative();
......@@ -1902,7 +1902,7 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
int queue = server.GetOutstandingCount(message.Command, out inst, out qu, out qs, out qc, out wr, out wq, out @in, out ar);
add("Instantaneous", "inst", inst.ToString());
#if !__MonoCS__ && !NETCORE
#if !__MonoCS__ && !DNXCORE50
add("Manager-State", "mgr", mgrState.ToString());
add("Last-Error", "err", lastError);
#endif
......@@ -1916,7 +1916,7 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
add("Active-Readers", "ar", ar.ToString());
add("Client-Name", "clientName", ClientName);
#if !NETCORE
#if !DNXCORE50
string iocp, worker;
int busyWorkerCount = GetThreadPoolStats(out iocp, out worker);
add("ThreadPool-IO-Completion", "IOCP", iocp);
......@@ -1953,7 +1953,7 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
}
}
#if !NETCORE
#if !DNXCORE50
private static int GetThreadPoolStats(out string iocp, out string worker)
{
//BusyThreads = TP.GetMaxThreads() –TP.GetAVailable();
......
......@@ -32,7 +32,7 @@ public HashEntry(RedisValue name, RedisValue value)
/// The name of the hash field
/// </summary>
[
#if !NETCORE
#if !DNXCORE50
Browsable(false),
#endif
EditorBrowsable(EditorBrowsableState.Never), Obsolete("Please use Name", false)]
......
#if NETCORE
#if DNXCORE50
using System;
#endif
using System.Text.RegularExpressions;
......@@ -11,7 +11,7 @@ internal static class InternalRegexCompiledOption
static InternalRegexCompiledOption()
{
#if NETCORE
#if DNXCORE50
if (!Enum.TryParse("Compiled", out RegexCompiledOption))
RegexCompiledOption = RegexOptions.None;
#else
......
......@@ -306,7 +306,7 @@ public int CompareTo(RedisValue other)
if (otherType == CompareType.Double) return thisDouble.CompareTo(otherDouble);
}
// otherwise, compare as strings
#if !NETCORE
#if !DNXCORE50
return StringComparer.InvariantCulture.Compare((string)this, (string)other);
#else
var compareInfo = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
......
......@@ -313,7 +313,7 @@ static void PrefixIfNeeded(ILGenerator il, LocalBuilder needsPrefixBool, ref Loc
LocalBuilder redisKeyLoc = null;
var loc = il.DeclareLocal(t);
il.Emit(OpCodes.Ldarg_0); // object
#if !NETCORE
#if !DNXCORE50
if (t.IsValueType)
#else
if (t.GetTypeInfo().IsValueType)
......@@ -348,7 +348,7 @@ static void PrefixIfNeeded(ILGenerator il, LocalBuilder needsPrefixBool, ref Loc
{
il.Emit(OpCodes.Dup); // RedisKey[] RedisKey[]
il.Emit(OpCodes.Ldc_I4, i); // RedisKey[] RedisKey[] int
#if !NETCORE
#if !DNXCORE50
if (t.IsValueType)
#else
if (t.GetTypeInfo().IsValueType)
......@@ -380,7 +380,7 @@ static void PrefixIfNeeded(ILGenerator il, LocalBuilder needsPrefixBool, ref Loc
{
il.Emit(OpCodes.Dup); // RedisKey[] RedisValue[] RedisValue[]
il.Emit(OpCodes.Ldc_I4, i); // RedisKey[] RedisValue[] RedisValue[] int
#if !NETCORE
#if !DNXCORE50
if (t.IsValueType)
#else
if (t.GetTypeInfo().IsValueType)
......
#if __MonoCS__ || NETCORE
#if __MonoCS__ || DNXCORE50
namespace StackExchange.Redis
{
......
......@@ -5,7 +5,7 @@
using System.Runtime.InteropServices;
using System.Threading;
#if !__MonoCS__ && !NETCORE
#if !__MonoCS__ && !DNXCORE50
namespace StackExchange.Redis
{
......@@ -376,12 +376,8 @@ private void ReadImpl()
private void StartReader()
{
#if !NETCORE
var thread = new Thread(read, 32 * 1024); // don't need a huge stack
thread.Priority = ThreadPriority.AboveNormal; // time critical
#else
var thread = new Thread(read); // don't need a huge stack
#endif
thread.Name = name + ":Read";
thread.IsBackground = true;
thread.Start(this);
......
......@@ -126,7 +126,7 @@ public SocketManager(string name = null)
// we need a dedicated writer, because when under heavy ambient load
// (a busy asp.net site, for example), workers are not reliable enough
#if !NETCORE
#if !DNXCORE50
Thread dedicatedWriter = new Thread(writeAllQueues, 32 * 1024); // don't need a huge stack;
dedicatedWriter.Priority = ThreadPriority.AboveNormal; // time critical
#else
......@@ -221,7 +221,7 @@ internal void SetFastLoopbackOption(Socket socket)
// SIO_LOOPBACK_FAST_PATH (http://msdn.microsoft.com/en-us/library/windows/desktop/jj841212%28v=vs.85%29.aspx)
// Speeds up localhost operations significantly. OK to apply to a socket that will not be hooked up to localhost,
// or will be subject to WFP filtering.
#if !NETCORE
#if !DNXCORE50
const int SIO_LOOPBACK_FAST_PATH = -1744830448;
// windows only
......@@ -340,7 +340,7 @@ private void Shutdown(Socket socket)
{
OnShutdown(socket);
try { socket.Shutdown(SocketShutdown.Both); } catch { }
#if !NETCORE
#if !DNXCORE50
try { socket.Close(); } catch { }
#endif
try { socket.Dispose(); } catch { }
......
......@@ -33,7 +33,7 @@ public SortedSetEntry(RedisValue element, double score)
/// The score against the element
/// </summary>
[
#if !NETCORE
#if !DNXCORE50
Browsable(false),
#endif
EditorBrowsable(EditorBrowsableState.Never), Obsolete("Please use Score", false)]
......@@ -43,7 +43,7 @@ public SortedSetEntry(RedisValue element, double score)
/// The unique element stored in the sorted set
/// </summary>
[
#if !NETCORE
#if !DNXCORE50
Browsable(false),
#endif
EditorBrowsable(EditorBrowsableState.Never), Obsolete("Please use Element", false)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment