public void Shutdown(Exception exception) { if (closed.CompareAndSet(false, true)) { messageQueue.Dispose(); failureCause = exception; Session.Remove(this); started.Set(false); } }
public async Task CloseAsync() { CheckIsOnDeliveryExecutionFlow(); if (closed.CompareAndSet(false, true)) { DoStop(false); foreach (NmsSession session in sessions.Values) { await session.ShutdownAsync(null).Await(); } ; try { await provider.CloseAsync().Await();; } catch (Exception) { Tracer.Debug("Ignoring provider exception during connection close"); } sessions.Clear(); started.Set(false); connected.Set(false); } }
public void Close() { CheckIsOnDeliveryThread(); if (closed.CompareAndSet(false, true)) { DoStop(false); foreach (NmsSession session in sessions.Values) { session.Shutdown(null); } try { provider.Close(); } catch (Exception) { Tracer.Debug("Ignoring provider exception during connection close"); } sessions.Clear(); started.Set(false); connected.Set(false); } }
/// <summary> /// Activates the Xamarin iOS specific support classes /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } Console.WriteLine("Loading support items"); Service.AutoRegister(typeof(iOS).Assembly); Console.WriteLine("Loading libLiteCore.dylib"); var dylibPath = Path.Combine(NSBundle.MainBundle.BundlePath, "libLiteCore.dylib"); if (!File.Exists(dylibPath)) { Console.WriteLine("Failed to find libLiteCore.dylib, nothing is going to work!"); } var loaded = ObjCRuntime.Dlfcn.dlopen(dylibPath, 0); if (loaded == IntPtr.Zero) { Console.WriteLine("Failed to load libLiteCore.dylib, nothing is going to work!"); var error = ObjCRuntime.Dlfcn.dlerror(); if (String.IsNullOrEmpty(error)) { Console.WriteLine("dlerror() was empty; most likely missing architecture"); } else { Console.WriteLine($"Error: {error}"); } } }
public void TestSetValueToFalse() { AtomicBool atomicBool = new AtomicBool(true); Assert.True(atomicBool.Value); atomicBool.Set(false); Assert.False(atomicBool.Value); }
/// <summary> /// Activates the support classes for UWP /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } Service.AutoRegister(typeof(UWP).GetTypeInfo().Assembly); }
/// <summary> /// Activates the support classes for Android /// </summary> /// <param name="context">The main context of the Android application</param> public static void Activate([NotNull] Context context) { if (_Activated.Set(true)) { return; } Service.AutoRegister(typeof(Droid).Assembly); Service.Register <IDefaultDirectoryResolver>(() => new DefaultDirectoryResolver(context)); Service.Register <IMainThreadTaskScheduler>(() => new MainThreadTaskScheduler(context)); }
/// <summary> /// Activates the support classes for UWP /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } Service.AutoRegister(typeof(UWP).GetTypeInfo().Assembly); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); }
/// <summary> /// Activates the Xamarin iOS specific support classes /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } Console.WriteLine("Loading support items"); Service.AutoRegister(typeof(iOS).Assembly); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); }
/// <summary> /// Activates the support classes for UWP /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } Service.AutoRegister(typeof(UWP).GetTypeInfo().Assembly); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); Service.Register <IProxy>(new UWPProxy()); Database.Log.Console = new UwpConsoleLogger(); }
/// <summary> /// Activates the Xamarin iOS specific support classes /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } Console.WriteLine("Loading support items"); Service.AutoRegister(typeof(iOS).Assembly); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); Service.Register <IProxy>(new IOSProxy()); Database.Log.Console = new iOSConsoleLogger(); }
/// <summary> /// Activates the support classes for Android /// </summary> /// <param name="context">The main context of the Android application</param> public static void Activate([NotNull] Context context) { if (_Activated.Set(true)) { return; } Service.AutoRegister(typeof(Droid).Assembly); Service.Register <IDefaultDirectoryResolver>(() => new DefaultDirectoryResolver(context)); Service.Register <IMainThreadTaskScheduler>(() => new MainThreadTaskScheduler(context)); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); Service.Register <IProxy>(new XamarinAndroidProxy()); }
/// <summary> /// Activates the Xamarin iOS specific support classes /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } Console.WriteLine("Loading support items for iOS"); Service.Register <IDefaultDirectoryResolver>(new DefaultDirectoryResolver()); Service.Register <IMainThreadTaskScheduler>(new MainThreadTaskScheduler()); Service.Register <IRuntimePlatform>(new iOSRuntimePlatform()); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); Service.Register <IProxy>(new IOSProxy()); }
public void Close() { lock (_tcpLock) if (_tcpClient.Connected) { SendMessage(new OutgoingMessage { Type = "closed" }); _tcpClient.Close(); } if (_workerThread.IsAlive && _workerThread != Thread.CurrentThread) { _workerThread.Abort(); } if (!_stoppedFlag.Set(true)) { Stopped?.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Activates the support classes for UWP /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } var version1 = typeof(UWP).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); var version2 = typeof(Database).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); if (!version1.Equals(version2)) { throw new InvalidOperationException( $"Mismatch between Couchbase.Lite and Couchbase.Lite.Support.UWP ({version2.InformationalVersion} vs {version1.InformationalVersion})"); } Service.AutoRegister(typeof(UWP).GetTypeInfo().Assembly); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); Service.Register <IProxy>(new UWPProxy()); Database.Log.Console = new UwpConsoleLogger(); }
/// <summary> /// Activates the support classes for .NET Core / .NET Framework /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } Service.AutoRegister(typeof(Unity).GetTypeInfo().Assembly); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Service.Register <IProxy>(new WindowsProxy()); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Service.Register <IProxy>(new MacProxy()); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Service.Register <IProxy>(new LinuxProxy()); } }
/// <summary> /// Activates the support classes for Android /// </summary> /// <param name="context">The main context of the Android application</param> public static void Activate([NotNull] Context context) { if (_Activated.Set(true)) { return; } var version1 = typeof(Droid).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); var version2 = typeof(Database).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); if (!version1.Equals(version2)) { throw new InvalidOperationException( $"Mismatch between Couchbase.Lite and Couchbase.Lite.Support.Android ({version2.InformationalVersion} vs {version1.InformationalVersion})"); } Service.AutoRegister(typeof(Droid).Assembly); Service.Register <IDefaultDirectoryResolver>(() => new DefaultDirectoryResolver(context)); Service.Register <IMainThreadTaskScheduler>(() => new MainThreadTaskScheduler(context)); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); Service.Register <IProxy>(new XamarinAndroidProxy()); Database.Log.Console = new AndroidConsoleLogger(); }
/// <summary> /// Activates the support classes for .NET Core / .NET Framework /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } var version1 = typeof(NetDesktop).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); var version2 = typeof(Database).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); if (!version1.Equals(version2)) { throw new InvalidOperationException( $"Mismatch between Couchbase.Lite and Couchbase.Lite.Support.NetDesktop ({version2.InformationalVersion} vs {version1.InformationalVersion})"); } if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { #if NETCOREAPP2_0 || NET461 var codeBase = Path.GetDirectoryName(typeof(NetDesktop).GetTypeInfo().Assembly.Location); if (codeBase == null) { throw new DllNotFoundException( "Couldn't find directory of the loaded support assembly, very weird!"); } #else var codeBase = AppContext.BaseDirectory; #endif var architecture = IntPtr.Size == 4 ? "x86" : "x64"; var nugetBase = codeBase; for (int i = 0; i < 2; i++) { nugetBase = Path.GetDirectoryName(nugetBase); } var dllPath = Path.Combine(codeBase, architecture, "LiteCore.dll"); var dllPathAsp = Path.Combine(codeBase, "bin", architecture, "LiteCore.dll"); var dllPathNuget = Path.Combine(nugetBase, "runtimes", $"win7-{architecture}", "native", "LiteCore.dll"); var foundPath = default(string); foreach (var path in new[] { dllPathNuget, dllPath, dllPathAsp }) { foundPath = File.Exists(path) ? path : null; if (foundPath != null) { break; } } if (foundPath == null) { throw new DllNotFoundException("Could not find LiteCore.dll! Nothing is going to work!\r\n" + "Tried searching in:\r\n" + $"{dllPathNuget}\r\n" + $"{dllPath}\r\n" + $"{dllPathAsp}\r\n"); } const uint loadWithAlteredSearchPath = 8; var ptr = LoadLibraryEx(foundPath, IntPtr.Zero, loadWithAlteredSearchPath); if (ptr == IntPtr.Zero) { if (CheckVS2015Redist()) { throw new BadImageFormatException( "Could not load LiteCore.dll! Nothing is going to work!\r\n" + $"LiteCore found in: ${foundPath}"); } throw new DllNotFoundException("LiteCore.dll failed to load! Please ensure that the Visual\r\n" + "Studio 2015 C++ runtime is installed from https://www.microsoft.com/en-us/download/details.aspx?id=48145"); } } Service.AutoRegister(typeof(NetDesktop).GetTypeInfo().Assembly); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Service.Register <IProxy>(new WindowsProxy()); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Service.Register <IProxy>(new MacProxy()); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Service.Register <IProxy>(new LinuxProxy()); } Database.Log.Console = new DesktopConsoleLogger(); }
/// <summary> /// Activates the support classes for .NET Core / .NET Framework /// </summary> public static void Activate() { if (_Activated.Set(true)) { return; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { #if NETCOREAPP2_0 || NET461 var codeBase = Path.GetDirectoryName(typeof(NetDesktop).GetTypeInfo().Assembly.Location); if (codeBase == null) { throw new DllNotFoundException( "Couldn't find directory of the loaded support assembly, very weird!"); } #else var codeBase = AppContext.BaseDirectory; #endif var architecture = IntPtr.Size == 4 ? "x86" : "x64"; var nugetBase = codeBase; for (int i = 0; i < 2; i++) { nugetBase = Path.GetDirectoryName(nugetBase); } var dllPath = Path.Combine(codeBase, architecture, "LiteCore.dll"); var dllPathAsp = Path.Combine(codeBase, "bin", architecture, "LiteCore.dll"); var dllPathNuget = Path.Combine(nugetBase, "runtimes", $"win7-{architecture}", "native", "LiteCore.dll"); var foundPath = default(string); foreach (var path in new[] { dllPathNuget, dllPath, dllPathAsp }) { foundPath = File.Exists(path) ? path : null; if (foundPath != null) { break; } } if (foundPath == null) { throw new DllNotFoundException("Could not find LiteCore.dll! Nothing is going to work!\r\n" + "Tried searching in:\r\n" + $"{dllPathNuget}\r\n" + $"{dllPath}\r\n" + $"{dllPathAsp}\r\n"); } const uint loadWithAlteredSearchPath = 8; var ptr = LoadLibraryEx(foundPath, IntPtr.Zero, loadWithAlteredSearchPath); if (ptr == IntPtr.Zero) { throw new BadImageFormatException("Could not load LiteCore.dll! Nothing is going to work!\r\n" + $"LiteCore found in: ${foundPath}"); } } Service.AutoRegister(typeof(NetDesktop).GetTypeInfo().Assembly); Service.Register <ILiteCore>(new LiteCoreImpl()); Service.Register <ILiteCoreRaw>(new LiteCoreRawImpl()); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Service.Register <IProxy>(new WindowsProxy()); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Service.Register <IProxy>(new MacProxy()); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Service.Register <IProxy>(new LinuxProxy()); } }
/// <summary> /// Skip current stage. /// </summary> /// <returns>Successfully set</returns> public bool Skip() => _stageSkipped.Set();