• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MAKE_PTR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MAKE_PTR函数的典型用法代码示例。如果您正苦于以下问题:C++ MAKE_PTR函数的具体用法?C++ MAKE_PTR怎么用?C++ MAKE_PTR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MAKE_PTR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: TestAllBuskeForces

    /**
     * Create a simulation of a NodeBasedCellPopulation with all Buske forces.
     * Test that no exceptions are thrown.
     */
    void TestAllBuskeForces() throw (Exception)
    {
        EXIT_IF_PARALLEL;    // HoneycombMeshGenerator doesn't work in parallel

        // Create a simple mesh
        HoneycombMeshGenerator generator(5, 5, 0);
        TetrahedralMesh<2,2>* p_generating_mesh = generator.GetMesh();

        // Convert this to a NodesOnlyMesh
        NodesOnlyMesh<2> mesh;
        mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);

        // Create cells
        std::vector<CellPtr> cells;
        MAKE_PTR(TransitCellProliferativeType, p_transit_type);
        CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes(), p_transit_type);

        // Create a node-based cell population
        NodeBasedCellPopulation<2> node_based_cell_population(mesh, cells);

        // Set up cell-based simulation
        OffLatticeSimulation<2> simulator(node_based_cell_population);
        simulator.SetOutputDirectory("TestAllBuskeForces");
        simulator.SetEndTime(5.0);

        // Create a force law and pass it to the simulation
        MAKE_PTR(BuskeCompressionForce<2>, p_buske_compression_force);
        MAKE_PTR(BuskeElasticForce<2>, p_buske_elastic_force);
        MAKE_PTR(BuskeAdhesiveForce<2>, p_buske_adhesive_force);
        p_buske_compression_force->SetCompressionEnergyParameter(0.01);
        simulator.AddForce(p_buske_compression_force);
        simulator.AddForce(p_buske_elastic_force);
        simulator.AddForce(p_buske_adhesive_force);

        simulator.Solve();
    }
开发者ID:Chaste,项目名称:Old-Chaste-svn-mirror,代码行数:41,代码来源:TestOffLatticeSimulationWithBuskeForces.hpp


示例2: TestOffLatticeSimulationWithCellHeightTrackingModifier

    /*
     * === Using the modifier in a cell-based simulation ===
     *
     * We conclude with a brief test demonstrating how {{{CellHeightTrackingModifier}}} can be used
     * in a cell-based simulation.
     */
    void TestOffLatticeSimulationWithCellHeightTrackingModifier()
    {
        /*
         * In this case, we choose to create a small {{{NodeBasedCellPopulation}}} comprising 25 cells.
         * We choose a cut-off for mechanical interactions between cells of 1.5 units and add a
         * simple {{{ReplusionForce}}} to the simulation. We use a {{{UniformCellCycleModel}}}
         * to implement some random proliferation in the simulation.
         */
        HoneycombMeshGenerator generator(2, 2, 0);
        TetrahedralMesh<2,2>* p_generating_mesh = generator.GetMesh();
        NodesOnlyMesh<2> mesh;
        mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);

        std::vector<CellPtr> cells;
        MAKE_PTR(TransitCellProliferativeType, p_transit_type);
        CellsGenerator<UniformCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes(), p_transit_type);

        NodeBasedCellPopulation<2> cell_population(mesh, cells);

        OffLatticeSimulation<2> simulator(cell_population);
        simulator.SetOutputDirectory("TestOffLatticeSimulationWithCellHeightTrackingModifier");
        simulator.SetSamplingTimestepMultiple(12);
        simulator.SetEndTime(20.0);

        MAKE_PTR(RepulsionForce<2>, p_force);
        simulator.AddForce(p_force);

        /*
         * Finally, we add a {{{CellHeightTrackingModifier}}} to the simulation.
         */
        MAKE_PTR(CellHeightTrackingModifier, p_modifier);
        simulator.AddSimulationModifier(p_modifier);

        /* To run the simulation, we call {{{Solve()}}}. */
        simulator.Solve();
    }
开发者ID:Chaste,项目名称:Chaste,代码行数:43,代码来源:TestCreatingAndUsingANewCellBasedSimulationModifierTutorial.hpp


示例3: TestSave

    void TestSave() throw (Exception)
    {
        EXIT_IF_PARALLEL;

        PottsMeshGenerator<2> generator(10, 0, 0, 10, 0, 0);
        PottsMesh<2>* p_mesh = generator.GetMesh();

        std::vector<CellPtr> cells;
        MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type);
        CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, 10, p_diff_type);

        std::vector<unsigned> location_indices;
        for (unsigned index=0; index<10; index++)
        {
            location_indices.push_back(index);
        }

        CaBasedCellPopulation<2> cell_population(*p_mesh, cells, location_indices, 4);

        // Set up cell-based simulation
        OnLatticeSimulation<2> simulator(cell_population);
        simulator.SetOutputDirectory("TestOnLatticeSimulationWithCaBasedCellPopulationSaveAndLoad");
        simulator.SetDt(1);
        simulator.SetEndTime(10);

        // Add update rule
        MAKE_PTR(DiffusionCaUpdateRule<2>, p_diffusion_update_rule);
        p_diffusion_update_rule->SetDiffusionParameter(0.1);
        simulator.AddCaUpdateRule(p_diffusion_update_rule);

        // Run simulation
        simulator.Solve();

        // Save the results
        CellBasedSimulationArchiver<2, OnLatticeSimulation<2> >::Save(&simulator);
    }
开发者ID:ktunya,项目名称:ChasteMod,代码行数:37,代码来源:TestOnLatticeSimulationWithCaBasedCellPopulation.hpp


示例4: TestSimpleMonolayerWithBuskeAdhesiveForce

    /**
     * Create a simulation of a NodeBasedCellPopulation with a BuskeInteractionForce system.
     * Test that no exceptions are thrown, and write the results to file.
     */
    void TestSimpleMonolayerWithBuskeAdhesiveForce() throw (Exception)
    {
        EXIT_IF_PARALLEL;    // HoneycombMeshGenerator doesn't work in parallel

        // Create a simple mesh
        HoneycombMeshGenerator generator(5, 5, 0);
        TetrahedralMesh<2,2>* p_generating_mesh = generator.GetMesh();

        // Convert this to a NodesOnlyMesh
        NodesOnlyMesh<2> mesh;
        mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);

        // Create cells
        std::vector<CellPtr> cells;
        CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes());

        // Create a node-based cell population
        NodeBasedCellPopulation<2> node_based_cell_population(mesh, cells);

        // Set up cell-based simulation
        OffLatticeSimulation<2> simulator(node_based_cell_population);
        simulator.SetOutputDirectory("TestOffLatticeSimulationWithBuskeAdhesiveForce");
        simulator.SetEndTime(5.0);

        // Create a force law and pass it to the simulation
        MAKE_PTR(BuskeAdhesiveForce<2>, p_buske_adhesive_force);
        p_buske_adhesive_force->SetAdhesionEnergyParameter(0.002);
        simulator.AddForce(p_buske_adhesive_force);

        simulator.Solve();

        // Check that nothing's gone badly wrong by testing that nodes aren't too close together
        double min_distance_between_cells = 1.0;

        for (unsigned i=0; i<simulator.rGetCellPopulation().GetNumNodes(); i++)
        {
            for (unsigned j=i+1; j<simulator.rGetCellPopulation().GetNumNodes(); j++)
            {
                double distance = norm_2(simulator.rGetCellPopulation().GetNode(i)->rGetLocation()-simulator.rGetCellPopulation().GetNode(j)->rGetLocation());
                if (distance < min_distance_between_cells)
                {
                    min_distance_between_cells = distance;
                }
            }
        }

        TS_ASSERT_LESS_THAN_EQUALS(1e-3, min_distance_between_cells);
    }
开发者ID:Chaste,项目名称:Old-Chaste-svn-mirror,代码行数:53,代码来源:TestOffLatticeSimulationWithBuskeForces.hpp


示例5: TestSave

    void TestSave() throw (Exception)
    {
        EXIT_IF_PARALLEL;    // Potts simulations don't work in parallel because they depend on NodesOnlyMesh for writing.

        // Create a simple 2D PottsMesh
        PottsMeshGenerator<2> generator(10, 1, 4, 10, 1, 4);
        PottsMesh<2>* p_mesh = generator.GetMesh();

        // Create cells
        std::vector<CellPtr> cells;
        MAKE_PTR(StemCellProliferativeType, p_stem_type);
        CellsGenerator<UniformlyDistributedGenerationBasedCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, p_mesh->GetNumElements(), p_stem_type);

        // Create cell population
        PottsBasedCellPopulation<2> cell_population(*p_mesh, cells);

        // Set up cell-based simulation
        OnLatticeSimulation<2> simulator(cell_population);
        simulator.SetOutputDirectory("TestOnLatticeSimulationWithPottsBasedCellPopulationSaveAndLoad");
        simulator.SetDt(0.1);
        simulator.SetEndTime(10);
        simulator.SetSamplingTimestepMultiple(10);

        // Create update rules and pass to the simulation
        MAKE_PTR(VolumeConstraintPottsUpdateRule<2>, p_volume_constraint_update_rule);
        simulator.AddPottsUpdateRule(p_volume_constraint_update_rule);
        MAKE_PTR(AdhesionPottsUpdateRule<2>, p_adhesion_update_rule);
        simulator.AddPottsUpdateRule(p_adhesion_update_rule);

        // Run simulation
        simulator.Solve();

        // Save the results
        CellBasedSimulationArchiver<2, OnLatticeSimulation<2> >::Save(&simulator);
    }
开发者ID:Chaste,项目名称:Old-Chaste-svn-mirror,代码行数:36,代码来源:TestOnLatticeSimulationWithPottsBasedCellPopulation.hpp


示例6: TestRandomCaSwitchingUpdateRuleIn2d

    /*
     * Now test the switching rules.
     */
    void TestRandomCaSwitchingUpdateRuleIn2d()
    {
        // Set the timestep and size of domain to let us calculate the probabilities of movement
        double delta_t = 0.1;
        double delta_x = 1;
        double switching_parameter = 0.1;

        // Create an update law system
        RandomCaSwitchingUpdateRule<2> random_switching_update_rule;

        // Test get/set methods
        TS_ASSERT_DELTA(random_switching_update_rule.GetSwitchingParameter(), 0.5, 1e-12);

        random_switching_update_rule.SetSwitchingParameter(1.0);

        TS_ASSERT_DELTA(random_switching_update_rule.GetSwitchingParameter(), 1.0, 1e-12);

        random_switching_update_rule.SetSwitchingParameter(switching_parameter);

        // Test EvaluateProbability()

        // Create a simple 2D PottsMesh
        PottsMeshGenerator<2> generator(3, 0, 0, 3, 0, 0);
        PottsMesh<2>* p_mesh = generator.GetMesh();

        // Create cells
        std::vector<CellPtr> cells;
        MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type);
        CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, 6u, p_diff_type);

        // Specify where cells lie here we have cells on the bottom two rows
        std::vector<unsigned> location_indices;

        for (unsigned i=0; i<6; i++)
        {
            location_indices.push_back(i);
        }

        // Create cell population
        CaBasedCellPopulation<2u> cell_population(*p_mesh, cells, location_indices);

        TS_ASSERT_DELTA(random_switching_update_rule.EvaluateSwitchingProbability(0,1,cell_population, delta_t, delta_x),switching_parameter*delta_t,1e-6);
        TS_ASSERT_DELTA(random_switching_update_rule.EvaluateSwitchingProbability(0,6,cell_population, delta_t, delta_x),switching_parameter*delta_t,1e-6);
        TS_ASSERT_DELTA(random_switching_update_rule.EvaluateSwitchingProbability(0,5,cell_population, delta_t, delta_x),switching_parameter*delta_t,1e-6);
        // Note this is independent of node index and population so even returns for nodes not in the mesh
        TS_ASSERT_DELTA(random_switching_update_rule.EvaluateSwitchingProbability(UNSIGNED_UNSET,UNSIGNED_UNSET,cell_population, delta_t, delta_x),switching_parameter*delta_t,1e-6);
    }
开发者ID:Chaste,项目名称:Chaste,代码行数:51,代码来源:TestCaUpdateRules.hpp


示例7: RemoveFirst

/*
 * RemoveFirst -- remove the first entry in the free list of ProcGlobal.
 *
 * Use compare_and_swap to avoid using lock and guarantee atomic operation.
 */
static PGPROC *
RemoveFirst()
{
	volatile PROC_HDR *procglobal = ProcGlobal;
	SHMEM_OFFSET myOffset;
	PGPROC *freeProc = NULL;

	/*
	 * Decrement numFreeProcs before removing the first entry from the
	 * free list.
	 */
	gp_atomic_add_32(&procglobal->numFreeProcs, -1);

	int32 casResult = false;
	while(!casResult)
	{
		myOffset = procglobal->freeProcs;

		if (myOffset == INVALID_OFFSET)
		{
			break;
		}
		
		freeProc = (PGPROC *) MAKE_PTR(myOffset);
			
		casResult = compare_and_swap_ulong(&((PROC_HDR *)procglobal)->freeProcs,
										   myOffset,
										   freeProc->links.next);

		if (gp_debug_pgproc && !casResult)
		{
			elog(LOG, "need to retry allocating a PGPROC entry: pid=%d (oldHeadOffset=%ld, newHeadOffset=%ld)",
				 MyProcPid, myOffset, procglobal->freeProcs);
		}

	}

	if (freeProc == NULL)
	{
		/*
		 * Increment numFreeProcs since we didn't remove any entry from
		 * the free list.
		 */
		gp_atomic_add_32(&procglobal->numFreeProcs, 1);
	}

	return freeProc;
}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:53,代码来源:proc.c


示例8: AbstractCellCycleModel

StatechartCellCycleModelSerializable::StatechartCellCycleModelSerializable(bool LoadingFromArchive): AbstractCellCycleModel(){
	
	mLoadingFromArchive=LoadingFromArchive;
	TempVariableStorage=std::vector<double>();
	TempStateStorage=0;

	//Set some sensible C.Elegans germ cell defaults
	mSDuration=8.33;
	mG2Duration=6.66;
	mMDuration=1.66;
	mG1Duration=3.33;
	mDimension=3;
	mCurrentCellCyclePhase=G_ONE_PHASE;
    
    MAKE_PTR(CellStatechart,newStatechart);
    pStatechart=newStatechart;
};
开发者ID:KathrynA,项目名称:ChasteElegansProject,代码行数:17,代码来源:StatechartCellCycleModelSerializable.cpp


示例9: TestCalculateWriteResultsToFile

    void TestCalculateWriteResultsToFile()
    {
        std::string output_directory = "TestDiscreteSystemForceCalculator";

        // Set up a cell population

        HoneycombMeshGenerator mesh_generator(7, 5, 0, 2.0);
        MutableMesh<2,2>* p_mesh = mesh_generator.GetMesh();

        CellsGenerator<FixedG1GenerationalCellCycleModel, 2> cells_generator;
        std::vector<CellPtr> cells;
        cells_generator.GenerateBasic(cells, p_mesh->GetNumNodes());

        MeshBasedCellPopulation<2> cell_population(*p_mesh, cells);

        // Create the force law and pass in to a std::list
        MAKE_PTR(GeneralisedLinearSpringForce<2>, p_force);
        std::vector<boost::shared_ptr<AbstractTwoBodyInteractionForce<2> > > force_collection;
        force_collection.push_back(p_force);

        // Create a force calculator
        DiscreteSystemForceCalculator calculator(cell_population, force_collection);

        // Test WriteResultsToFile
        calculator.WriteResultsToFile(output_directory);

        // Compare output with saved files of what they should look like
        OutputFileHandler handler(output_directory, false);
        std::string results_file = handler.GetOutputDirectoryFullPath() + "results_from_time_0/results.vizstress";

        NumericFileComparison node_velocities(results_file, "cell_based/test/data/TestDiscreteSystemForceCalculator/results.vizstress");
        TS_ASSERT(node_velocities.CompareFiles(1e-4));

        // Run a simulation to generate some results.viz<other things> files
        // so the visualizer can display the results.vizstress file.
        // (These lines are not actually necessary for generating results.vizstress)
        OffLatticeSimulation<2> simulator(cell_population);

        simulator.AddForce(p_force);

        simulator.SetEndTime(0.05);
        simulator.SetOutputDirectory(output_directory+"_rerun");
        simulator.Solve();
    }
开发者ID:Chaste,项目名称:Chaste,代码行数:44,代码来源:TestDiscreteSystemForceCalculator.hpp


示例10: InitBufferPool

void
InitBufferPool () {

	int	i;

	PrivateRefCount = (long *) malloc(NBuffers * sizeof(long));

	// Altered to use regular memory
	BufferDescriptors = (BufferDesc *) malloc (NBuffers * sizeof(BufferDesc));
    BufferBlocks = (char *) malloc (NBuffers * BLCKSZ);

	ShmemBase = BufferBlocks;
	// ShmemBase = (unsigned long) BufferBlocks;

	if (false)
	{
	}
	else
	{
		BufferDesc *buf;
		buf = BufferDescriptors;

		for (i = 0; i < NBuffers; buf++, i++)
		{
			CLEAR_BUFFERTAG(buf->tag);
			buf->flags    = 0;
			buf->usage_count = 0;
			buf->refcount = 0;
			buf->wait_backend_pid = 0;
			buf->freeNext = i + 1;
			buf->buf_id = i;

			*((char *) MAKE_PTR(i * BLCKSZ)) = '#';

			buf->io_in_progress_lock = LWLockAssign();
			buf->content_lock = LWLockAssign();
		}

		/* close the circular queue */
                BufferDescriptors[NBuffers - 1].freeNext = -1;
		StrategyInitialize(true);
	}

}
开发者ID:bilun167,项目名称:cs3223,代码行数:44,代码来源:stubs.c


示例11: TestSave

    // Testing Save
    void TestSave() throw (Exception)
    {
        EXIT_IF_PARALLEL; // HoneycombMeshGenereator does not work in parallel

        // Create a simple mesh
        int num_cells_depth = 5;
        int num_cells_width = 5;
        HoneycombMeshGenerator generator(num_cells_width, num_cells_depth, 0);
        TetrahedralMesh<2,2>* p_generating_mesh = generator.GetMesh();

        // Convert this to a NodesOnlyMesh
        NodesOnlyMesh<2> mesh;
        mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);

        // Create cells
        std::vector<CellPtr> cells;
        CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes());

        // Create a node based cell population
        NodeBasedCellPopulation<2> node_based_cell_population(mesh, cells);

        // Set up cell-based simulation
        OffLatticeSimulation<2> simulator(node_based_cell_population);
        simulator.SetOutputDirectory("TestOffLatticeSimulationWithNodeBasedCellPopulationSaveAndLoad");
        simulator.SetEndTime(0.1);

        // Create a force law and pass it to the simulation
        MAKE_PTR(GeneralisedLinearSpringForce<2>, p_linear_force);
        p_linear_force->SetCutOffLength(1.5);
        simulator.AddForce(p_linear_force);

        // Create some boundary conditions and pass them to the simulation
        c_vector<double,2> normal = zero_vector<double>(2);
        normal(1) =-1.0;
        MAKE_PTR_ARGS(PlaneBoundaryCondition<2>, p_bc, (&node_based_cell_population, zero_vector<double>(2), normal)); // y>0
        simulator.AddCellPopulationBoundaryCondition(p_bc);

        // Solve
        simulator.Solve();

        // Save the results
        CellBasedSimulationArchiver<2, OffLatticeSimulation<2> >::Save(&simulator);
    }
开发者ID:Pablo1990,项目名称:ChasteSimulation,代码行数:45,代码来源:TestOffLatticeSimulationWithNodeBasedCellPopulation.hpp


示例12: InitBufferPoolAccess

/*
 * Initialize access to shared buffer pool
 *
 * This is called during backend startup (whether standalone or under the
 * postmaster).  It sets up for this backend's access to the already-existing
 * buffer pool.
 *
 * NB: this is called before InitProcess(), so we do not have a PGPROC and
 * cannot do LWLockAcquire; hence we can't actually access the bufmgr's
 * shared memory yet.  We are only initializing local data here.
 */
void
InitBufferPoolAccess(void)
{
	int			i;

	/*
	 * Allocate and zero local arrays of per-buffer info.
	 */
	BufferBlockPointers = (Block *) calloc(NBuffers, sizeof(Block));
	PrivateRefCount = (long *) calloc(NBuffers, sizeof(long));
	BufferLocks = (bits8 *) calloc(NBuffers, sizeof(bits8));

	/*
	 * Convert shmem offsets into addresses as seen by this process. This
	 * is just to speed up the BufferGetBlock() macro.
	 */
	for (i = 0; i < NBuffers; i++)
		BufferBlockPointers[i] = (Block) MAKE_PTR(BufferDescriptors[i].data);
}
开发者ID:guzhuo0624,项目名称:workonsql,代码行数:30,代码来源:buf_init.c


示例13: TestMoreOnLatticeSimulationExceptions

    void TestMoreOnLatticeSimulationExceptions()
    {
        // Create a simple 2D PottsMesh
        PottsMeshGenerator<2> generator(6, 2, 2, 6, 2, 2);
        PottsMesh<2>* p_mesh = generator.GetMesh();

        // Create cells
        std::vector<CellPtr> cells;
        MAKE_PTR(DifferentiatedCellProliferativeType, p_diff_type);
        CellsGenerator<FixedDurationGenerationBasedCellCycleModel, 2> cells_generator;
        cells_generator.GenerateBasicRandom(cells, p_mesh->GetNumElements(), p_diff_type);

        // Create cell population
        PottsBasedCellPopulation<2> potts_based_cell_population(*p_mesh, cells);

        // Try to set up off lattice simulation
        TS_ASSERT_THROWS_THIS(OffLatticeSimulation<2> simulator(potts_based_cell_population),
            "OffLatticeSimulations require a subclass of AbstractOffLatticeCellPopulation.");
    }
开发者ID:Chaste,项目名称:Old-Chaste-svn-mirror,代码行数:19,代码来源:TestOnLatticeSimulationWithPottsBasedCellPopulation.hpp


示例14: GetOldestXmin

/*
 * GetOldestXmin -- returns oldest transaction that was running
 *					when any current transaction was started.
 *
 * If allDbs is TRUE then all backends are considered; if allDbs is FALSE
 * then only backends running in my own database are considered.
 *
 * This is used by VACUUM to decide which deleted tuples must be preserved
 * in a table.	allDbs = TRUE is needed for shared relations, but allDbs =
 * FALSE is sufficient for non-shared relations, since only backends in my
 * own database could ever see the tuples in them.
 *
 * Note: we include the currently running xids in the set of considered xids.
 * This ensures that if a just-started xact has not yet set its snapshot,
 * when it does set the snapshot it cannot set xmin less than what we compute.
 */
TransactionId
GetOldestXmin(bool allDbs)
{
	SISeg	   *segP = shmInvalBuffer;
	ProcState  *stateP = segP->procState;
	TransactionId result;
	int			index;

	result = GetCurrentTransactionId();

	LWLockAcquire(SInvalLock, LW_SHARED);

	for (index = 0; index < segP->lastBackend; index++)
	{
		SHMEM_OFFSET pOffset = stateP[index].procStruct;

		if (pOffset != INVALID_OFFSET)
		{
			PGPROC	   *proc = (PGPROC *) MAKE_PTR(pOffset);

			if (allDbs || proc->databaseId == MyDatabaseId)
			{
				/* Fetch xid just once - see GetNewTransactionId */
				TransactionId xid = proc->xid;

				if (TransactionIdIsNormal(xid))
				{
					if (TransactionIdPrecedes(xid, result))
						result = xid;
					xid = proc->xmin;
					if (TransactionIdIsNormal(xid))
						if (TransactionIdPrecedes(xid, result))
							result = xid;
				}
			}
		}
	}

	LWLockRelease(SInvalLock);

	return result;
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:58,代码来源:sinval.c


示例15: ProcLockWakeup

/*
 * ProcLockWakeup -- routine for waking up processes when a lock is
 * 	released.
 */
int
ProcLockWakeup(PROC_QUEUE *queue, char *ltable, char *lock)
{
    PROC	*proc;
    int	count;
    
    if (! queue->size)
	return(STATUS_NOT_FOUND);
    
    proc = (PROC *) MAKE_PTR(queue->links.prev);
    count = 0;
    while ((LockResolveConflicts ((LOCKTAB *) ltable,
				  (LOCK *) lock,
				  proc->token,
				  proc->xid) == STATUS_OK))
	{
	    /* there was a waiting process, grant it the lock before waking it
	     * up.  This will prevent another process from seizing the lock
	     * between the time we release the lock master (spinlock) and
	     * the time that the awoken process begins executing again.
	     */
	    GrantLock((LOCK *) lock, proc->token);
	    queue->size--;
	    
	    /*
	     * ProcWakeup removes proc from the lock waiting process queue and
	     * returns the next proc in chain.  If a writer just dropped
	     * its lock and there are several waiting readers, wake them all up.
	     */
	    proc = ProcWakeup(proc, NO_ERROR);
	    
	    count++;
	    if (!proc || queue->size == 0)
		break;
	}
    
    if (count)
	return(STATUS_OK);
    else
	/* Something is still blocking us.  May have deadlocked. */
	return(STATUS_NOT_FOUND);
}
开发者ID:jarulraj,项目名称:postgres95,代码行数:46,代码来源:proc.c


示例16: BackendIdGetProc

/*
 * BackendIdGetProc - given a BackendId, find its PGPROC structure
 *
 * This is a trivial lookup in the ProcState array.  We assume that the caller
 * knows that the backend isn't going to go away, so we do not bother with
 * locking.
 */
struct PGPROC *
BackendIdGetProc(BackendId procId)
{
	SISeg	   *segP = shmInvalBuffer;

	if (procId > 0 && procId <= segP->lastBackend)
	{
		ProcState  *stateP = &segP->procState[procId - 1];
		SHMEM_OFFSET pOffset = stateP->procStruct;

		if (pOffset != INVALID_OFFSET)
		{
			PGPROC	   *proc = (PGPROC *) MAKE_PTR(pOffset);

			return proc;
		}
	}

	return NULL;
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:27,代码来源:sinval.c


示例17: InitBufferPoolAccess

/*
 * Initialize access to shared buffer pool
 *
 * This is called during backend startup (whether standalone or under the
 * postmaster).  It sets up for this backend's access to the already-existing
 * buffer pool.
 *
 * NB: this is called before InitProcess(), so we do not have a PGPROC and
 * cannot do LWLockAcquire; hence we can't actually access the bufmgr's
 * shared memory yet.  We are only initializing local data here.
 */
void
InitBufferPoolAccess(void)
{
	int			i;

	/*
	 * Allocate and zero local arrays of per-buffer info.
	 */
	BufferBlockPointers = (Block *) calloc(NBuffers,
										   sizeof(*BufferBlockPointers));
	PrivateRefCount = (int32 *) calloc(NBuffers,
									   sizeof(*PrivateRefCount));

	/*
	 * Convert shmem offsets into addresses as seen by this process. This
	 * is just to speed up the BufferGetBlock() macro.  It is OK to do this
	 * without any lock since the data pointers never change.
	 */
	for (i = 0; i < NBuffers; i++)
		BufferBlockPointers[i] = (Block) MAKE_PTR(BufferDescriptors[i].data);
}
开发者ID:berkeley-cs186,项目名称:course-fa07,代码行数:32,代码来源:buf_init.c


示例18: SHMQueueInsertBefore

/*
 * SHMQueueInsertBefore -- put elem in queue before the given queue
 *		element.  Inserting "before" the queue head puts the elem
 *		at the tail of the queue.
 */
void
SHMQueueInsertBefore(SHM_QUEUE *queue, SHM_QUEUE *elem)
{
	SHM_QUEUE  *prevPtr = (SHM_QUEUE *) MAKE_PTR((queue)->prev);
	SHMEM_OFFSET elemOffset = MAKE_OFFSET(elem);

	Assert(SHM_PTR_VALID(queue));
	Assert(SHM_PTR_VALID(elem));

#ifdef SHMQUEUE_DEBUG
	dumpQ(queue, "in SHMQueueInsertBefore: begin");
#endif

	(elem)->next = prevPtr->next;
	(elem)->prev = queue->prev;
	(queue)->prev = elemOffset;
	prevPtr->next = elemOffset;

#ifdef SHMQUEUE_DEBUG
	dumpQ(queue, "in SHMQueueInsertBefore: end");
#endif
}
开发者ID:50wu,项目名称:gpdb,代码行数:27,代码来源:shmqueue.c


示例19: TestSimpleTargetAreaModifierOutputParameters

    void TestSimpleTargetAreaModifierOutputParameters()
    {
        EXIT_IF_PARALLEL;
        std::string output_directory = "TestSimpleTargetAreaModifierOutputParameters";
        OutputFileHandler output_file_handler(output_directory, false);

        MAKE_PTR(SimpleTargetAreaModifier<2>, p_modifier);
        TS_ASSERT_EQUALS(p_modifier->GetIdentifier(), "SimpleTargetAreaModifier-2");

        out_stream modifier_parameter_file = output_file_handler.OpenOutputFile("SimpleTargetAreaModifier.parameters");
        p_modifier->OutputSimulationModifierParameters(modifier_parameter_file);
        modifier_parameter_file->close();

        {
            // Compare the generated file in test output with a reference copy in the source code
            FileFinder generated = output_file_handler.FindFile("SimpleTargetAreaModifier.parameters");
            FileFinder reference("cell_based/test/data/TestSimulationModifierOutputParameters/SimpleTargetAreaModifier.parameters",
                    RelativeTo::ChasteSourceRoot);
            FileComparison comparer(generated, reference);
            TS_ASSERT(comparer.CompareFiles());
        }
    }
开发者ID:Chaste,项目名称:Old-Chaste-svn-mirror,代码行数:22,代码来源:TestSimpleTargetAreaModifier.hpp


示例20: ProcWakeup

/*
 * ProcWakeup -- wake up a process by releasing its private semaphore.
 *
 *   remove the process from the wait queue and set its links invalid.
 *   RETURN: the next process in the wait queue.
 */
PROC *
ProcWakeup(PROC *proc, int errType)
{
    PROC *retProc;
    /* assume that spinlock has been acquired */
    
    if (proc->links.prev == INVALID_OFFSET ||
	proc->links.next == INVALID_OFFSET)
	return((PROC *) NULL);
    
    retProc = (PROC *) MAKE_PTR(proc->links.prev);
    
    /* you have to update waitLock->waitProcs.size yourself */
    SHMQueueDelete(&(proc->links));
    SHMQueueElemInit(&(proc->links));
    
    proc->errType = errType;
    
    IpcSemaphoreUnlock(proc->sem.semId, proc->sem.semNum, IpcExclusiveLock);
    
    return retProc;
}
开发者ID:jarulraj,项目名称:postgres95,代码行数:28,代码来源:proc.c



注:本文中的MAKE_PTR函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MAKE_RGB函数代码示例发布时间:2022-05-30
下一篇:
C++ MAKE_PAIR32函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap