Inheritance: FdbSafeHandle
Example #1
0
        public static FdbError DatabaseCreateTransaction(DatabaseHandle database, out TransactionHandle transaction)
        {
            var err = NativeMethods.fdb_database_create_transaction(database, out transaction);

#if DEBUG_NATIVE_CALLS
            Debug.WriteLine("fdb_database_create_transaction(0x" + database.Handle.ToString("x") + ") => err=" + err + ", handle=0x" + transaction.Handle.ToString("x"));
#endif
            return(err);
        }
		public FdbNativeDatabase(DatabaseHandle handle)
		{
			if (handle == null) throw new ArgumentNullException("handle");

			m_handle = handle;
#if CAPTURE_STACKTRACES
			m_stackTrace = new StackTrace();
#endif
		}
Example #3
0
        public static FdbError FutureGetDatabase(FutureHandle future, out DatabaseHandle database)
        {
            var err = NativeMethods.fdb_future_get_database(future, out database);

#if DEBUG_NATIVE_CALLS
            Debug.WriteLine("fdb_future_get_database(0x" + future.Handle.ToString("x") + ") => err=" + err + ", handle=0x" + database.Handle.ToString("x"));
#endif
            //TODO: check if err == Success ?
            return(err);
        }
        public FdbNativeDatabase(DatabaseHandle handle, string?clusterFile, ClusterHandle?cluster = null)
        {
            Contract.NotNull(handle, nameof(handle));

            m_handle        = handle;
            m_clusterFile   = clusterFile;
            m_clusterHandle = cluster;
#if CAPTURE_STACKTRACES
            m_stackTrace = new StackTrace();
#endif
        }
        public FdbNativeDatabase(DatabaseHandle handle)
        {
            if (handle == null)
            {
                throw new ArgumentNullException("handle");
            }

            m_handle = handle;
#if CAPTURE_STACKTRACES
            m_stackTrace = new StackTrace();
#endif
        }
Example #6
0
        private static async ValueTask <IFdbDatabaseHandler> CreateDatabaseLegacyAsync(string clusterFile, CancellationToken ct)
        {
            // In legacy API versions, you first had to create "cluster" handle and then obtain a database handle that that cluster.
            // The API is async, but the future always completed inline...

            ClusterHandle  cluster  = null;
            DatabaseHandle database = null;

            try
            {
                cluster = await FdbFuture.CreateTaskFromHandle(
                    FdbNative.CreateCluster(clusterFile),
                    h =>
                {
                    var err = FdbNative.FutureGetCluster(h, out var handle);
                    if (err != FdbError.Success)
                    {
                        throw Fdb.MapToException(err);
                    }

                    return(handle);
                },
                    ct).ConfigureAwait(false);

                database = await FdbFuture.CreateTaskFromHandle(
                    FdbNative.ClusterCreateDatabase(cluster, "DB"),
                    h =>
                {
                    var err = FdbNative.FutureGetDatabase(h, out var handle);
                    if (err != FdbError.Success)
                    {
                        throw Fdb.MapToException(err);
                    }

                    return(handle);
                },
                    ct).ConfigureAwait(false);

                return(new FdbNativeDatabase(database, clusterFile, cluster));
            }
            catch (Exception)
            {
                database?.Dispose();
                cluster?.Dispose();
                throw;
            }
        }
Example #7
0
 public static FdbError DatabaseSetOption(DatabaseHandle database, FdbDatabaseOption option, byte *value, int valueLength)
 {
     return(NativeMethods.fdb_database_set_option(database, option, value, valueLength));
 }
Example #8
0
 public static extern FdbError fdb_future_get_database(FutureHandle future, out DatabaseHandle database);
Example #9
0
 public static extern FdbError fdb_database_create_transaction(DatabaseHandle database, out TransactionHandle transaction);
Example #10
0
 public static extern FdbError fdb_database_set_option(DatabaseHandle handle, FdbDatabaseOption option, byte *value, int valueLength);
		public static FdbError DatabaseCreateTransaction(DatabaseHandle database, out TransactionHandle transaction)
		{
			var err = NativeMethods.fdb_database_create_transaction(database, out transaction);
#if DEBUG_NATIVE_CALLS
			Debug.WriteLine("fdb_database_create_transaction(0x" + database.Handle.ToString("x") + ") => err=" + err + ", handle=0x" + transaction.Handle.ToString("x"));
#endif
			return err;
		}
		public static FdbError DatabaseSetOption(DatabaseHandle database, FdbDatabaseOption option, byte* value, int valueLength)
		{
			return NativeMethods.fdb_database_set_option(database, option, value, valueLength);
		}
		public static FdbError FutureGetDatabase(FutureHandle future, out DatabaseHandle database)
		{
			var err = NativeMethods.fdb_future_get_database(future, out database);
#if DEBUG_NATIVE_CALLS
			Debug.WriteLine("fdb_future_get_database(0x" + future.Handle.ToString("x") + ") => err=" + err + ", handle=0x" + database.Handle.ToString("x"));
#endif
			//TODO: check if err == Success ?
			return err;
		}
			public static extern FdbError fdb_future_get_database(FutureHandle future, out DatabaseHandle database);
			public static extern FdbError fdb_database_create_transaction(DatabaseHandle database, out TransactionHandle transaction);
			public static extern FdbError fdb_database_set_option(DatabaseHandle handle, FdbDatabaseOption option, byte* value, int valueLength);