示例#1
0
  void
  solver_type::
ensure_buffer_size
 (  solve_1d_functor_type
                     const &  calc_1d_functor
  , size_type                 x_size
  , size_type                 y_size
 )
  // The 1d functors know how big a buffer they need.
{
    // Make sure the buffers are big enough to handle the solve.
    // And shrink them or release them if they are too big.
    if ( not_early_exit( ) ) {
        size_type const now_buf_size = buf_a_.size( );
        size_type const min_buf_size = calc_1d_functor.get_min_buf_count( x_size, y_size);
        if ( (min_buf_size > now_buf_size) ||
             (min_buf_size < (now_buf_size / 2)) )
        {
            if ( min_buf_size == 0 ) {
                clear_buffers( );
            } else {
                buf_a_.resize( min_buf_size); buf_iter_a_ = buf_a_.begin( );
                buf_b_.resize( min_buf_size); buf_iter_b_ = buf_b_.begin( );
            }
        }
        d_assert( buf_a_.size( ) >= min_buf_size);
        d_assert( buf_b_.size( ) >= min_buf_size);
    }
}
示例#2
0
const char * DBConnector::GetString(int i)
{
	d_assert (mysql_row != NULL);
	d_assert (i < (int)mysql_num_fields(mysql_result));

	return mysql_row[i];
}
示例#3
0
  void
  double_slide_holder::
set_values
 (  value_type  val
 ,  value_type  min
 ,  value_type  max
 ,  value_type  ss   // -1 means use existing value
 ,  value_type  ps   // -1 means use existing value
 )
{
    d_assert( ! is_setting( ));

    // We generate our own signals instead of relying on the inner object.
    while_setting_value_wrapper_type wrapper( this, false);
    d_assert( is_setting( ));

    // Remember the old values.
    value_type const  old_val  =  get_value( );
    value_type const  old_min  =  get_min_value( );
    value_type const  old_max  =  get_max_value( );
    value_type const  old_ss   =  get_single_step( );
    value_type const  old_ps   =  get_page_step( );

    // Must do this before the conversions that follow.
    setup_conversions( min, max);

    // Send the values to the inner holder.
    p_inner_holder_->
      set_values
       (  convert_outer_to_inner( val)
        , convert_outer_to_inner( min)
        , convert_outer_to_inner( max)
        , convert_outer_to_inner_distance( ss)
        , convert_outer_to_inner_distance( ps)
       );

    // Find the new values. These may be slightly different due to rounding etc.
    value_type const  new_val  =  get_value( );
    value_type const  new_min  =  get_min_value( );
    value_type const  new_max  =  get_max_value( );
    value_type const  new_ss   =  get_single_step( );
    value_type const  new_ps   =  get_page_step( );

    // Emit the value signals.
    if ( (new_ss != old_ss) || (new_ps != old_ps) ) {
        emit has_changed__steps( new_ss, new_ps);
        wrapper.request_signal( );
    }
    if ( (new_min != old_min) || (new_max != old_max) ) {
        emit has_changed__range( new_min, new_max);
        wrapper.request_signal( );
    }
    if ( new_val != old_val ) {
        emit has_changed( new_val);
        wrapper.request_signal( );
    }

    // The wrapper dtor will signal has_changed( ) if appropriate.
    wrapper.done_with_no_throws( );
}
示例#4
0
	void TerrainLayerDlg::_notifyEditLayer(Event * _sender)
	{
		if (mLayerInfoDlg->GetLayer() == NULL) // is add
			return ;

		Terrain * tn = Environment::Instance()->GetTerrain();

		int layerId = GetCurLayer();

		d_assert (layerId != -1);

		Terrain::Layer layer;

		layer.detail = mLayerInfoDlg->GetDiffuseMap();
		layer.normal = mLayerInfoDlg->GetNormalMap();
		layer.specular = mLayerInfoDlg->GetSpecularMap();
		layer.scale = mLayerInfoDlg->GetUVScale();
		layer.material = -1;

		tn->SetLayer(layerId, layer);

		size_t isel = mLayerList->getIndexSelected();

		d_assert (isel != MyGUI::ITEM_NONE);

		mLayerList->setItemNameAt(isel, layer.detail.c_wstr());
	}
示例#5
0
void memory_session::begin()
{
    scoped_lock l(mutex);
    d_assert(unfrozen_threads_count != UNINITIALIZED, "Memory session begin() while uninitialized");

    const bool currently_frozen = (unfrozen_threads_count == 0);
    // is zero only on first begin() of current thread with this session
    if (!frozen.get())
    {
        frozen.reset(new bool(currently_frozen));

        if (unfrozen_threads_count > 0)
            ++unfrozen_threads_count;
            // session right after init() is unfrozen
        else if (unfrozen_threads_count == NOTSTARTED)
            unfrozen_threads_count = 1;
    }
    else
    {
        d_assert(unfrozen_threads_count >= 0, "unfrozen_threads_count == " << unfrozen_threads_count);

        *frozen.get() = currently_frozen;

        if (!currently_frozen)
            ++unfrozen_threads_count;
    }

    default_sub_session->begin();
}
示例#6
0
  void
  int_range_steps_holder::
attach( QSpinBox * p_spinb)
{
    d_assert( p_spinb);

    // Move the values.
    d_assert( is_valid( ));
    //if ( init_value_from_holder ) {
        move_values_to( p_spinb);
    //} else {
    //  set_values_from( p_spinb);
    //}
    d_assert( is_valid( ));

    // Put the widget on the list.
    d_assert( ! attached_widgets_.contains( p_spinb));
    attached_widgets_.push_front( p_spinb);
    d_verify( connect(
        p_spinb, SIGNAL( destroyed( QObject *)),
        this, SLOT( before_dtor( QObject *))
    ));

    // Watch for a signal from the UI.
    d_verify( connect( p_spinb, SIGNAL( valueChanged( int)), this, SLOT( set_value( int))));

    // We also need to relay changes here back to the UI objects. We could do it by intercepting
    // these signals from this object:
    //   has_changed( int)
    //   has_changed__range( int, int)
    //   has_changed__steps( int, int)
    // But since the ctrl classes don't have the slots to support this, so instead we loop thru
    // our list of attached widgets and set these values explicitly. See move_values_to(..) and
    // set_values(..).
}
示例#7
0
  /* static */
  int
  pack_range_steps_holder::
convert_log_pack_to_ui( double d_log_pack)
  //
  // Used when you want to map a double value to a log-scale integer.
  // Double must be > 0. Doubles map to integers as follows:
  //
  //   log_pack   ui == 1000 * std::log( log_pack)
  //   =======    ================
  //   0.0001  -> -9210
  //   0.001   -> -6908
  //   0.01    -> -4605
  //   0.1     -> -2303
  //   1.0     -> 0
  //   10.0    -> +2303
  //   100.0   -> +4605
  //   1000.0  -> +6908
  //   10000.0 -> +9210
  {
    // ln( 10000) is slightly more than +9.21
    // ln( .0001) is slightly less than -9.21
    d_assert( (0.0001 <= d_log_pack) && (d_log_pack <= 10000.0)); // is_valid_log_pack
    // std::log(..) is natural log. std::log10(..) is log-base-10.
    double const d_linear_pack = std::log( d_log_pack);
    int const i_ui = convert_linear_pack_to_ui( d_linear_pack);
    d_assert( (-10000 <= i_ui) && (i_ui <= 10000)); // is_valid_ui_for_log_pack
    return i_ui;
  }
示例#8
0
  void
  int_range_steps_holder::
attach( QAbstractSlider * p_slider)
{
    d_assert( p_slider);

    // Move the values.
    d_assert( is_valid( ));
    //if ( init_value_from_holder ) {
        move_values_to( p_slider);
    //} else {
    //  set_values_from( p_slider);
    //}
    d_assert( is_valid( ));

    // Put the widget on the list.
    d_assert( ! attached_widgets_.contains( p_slider));
    attached_widgets_.push_front( p_slider);
    d_verify( connect(
        p_slider, SIGNAL( destroyed( QObject *)),
        this, SLOT( before_dtor( QObject *))
    ));

    // Watch for a signal from the UI.
    d_verify( connect( p_slider, SIGNAL( valueChanged( int)), this, SLOT( set_value( int))));

    // We don't connect back the other way (from this object to the UI) because the UI classes
    // don't have the right slots. Instead we keep these objects updated in set_values(..).
}
示例#9
0
GizmoBar::GizmoBar()
{
	mLayout = MGUI::Layout::Load("GizmoBar.layout", NULL);
	mLayout->SetVisible(false);

	mWidget_Move = mLayout->GetChild("Move"); d_assert (mWidget_Move);
	mWidget_Rotate = mLayout->GetChild("Rotate"); d_assert (mWidget_Rotate);
	mWidget_Scale = mLayout->GetChild("Scale"); d_assert (mWidget_Scale);

	mWidget_Move->SetAlpha(1.0f);
	mWidget_Rotate->SetAlpha(0.5f);
	mWidget_Scale->SetAlpha(0.5f);

	mWidget_Move->E_MouseClick += new cListener1<GizmoBar, const MGUI::MouseEvent *>(this, &GizmoBar::OnMove);
	mWidget_Rotate->E_MouseClick += new cListener1<GizmoBar, const MGUI::MouseEvent *>(this, &GizmoBar::OnRotate);
	mWidget_Scale->E_MouseClick += new cListener1<GizmoBar, const MGUI::MouseEvent *>(this, &GizmoBar::OnScale);

	mEditBox_X = (MGUI::EditBox *)mLayout->GetChild("x");
	mEditBox_Y = (MGUI::EditBox *)mLayout->GetChild("y");
	mEditBox_Z = (MGUI::EditBox *)mLayout->GetChild("z");

	mEditBox_X->E_KeyLostFocus += new cListener1<GizmoBar, const MGUI::FocusEvent *>(this, &GizmoBar::OnTextChanged);
	mEditBox_Y->E_KeyLostFocus += new cListener1<GizmoBar, const MGUI::FocusEvent *>(this, &GizmoBar::OnTextChanged);
	mEditBox_Z->E_KeyLostFocus += new cListener1<GizmoBar, const MGUI::FocusEvent *>(this, &GizmoBar::OnTextChanged);

	Editor::Instance()->E_NodeSelect += new cListener0<GizmoBar>(this, &GizmoBar::OnNodeSelect);
	Editor::Instance()->E_NodePositionChanged += new cListener0<GizmoBar>(this, &GizmoBar::OnPositionChanged); 
	Editor::Instance()->E_NodeRotationChanged += new cListener0<GizmoBar>(this, &GizmoBar::OnRotationChanged); 
	Editor::Instance()->E_NodeScaleChanged += new cListener0<GizmoBar>(this, &GizmoBar::OnScaleChanged); 
}
示例#10
0
	void MGUI_RenderSystem::initialise()
	{
		d_assert (!mIsInitialise);

		MYGUI_PLATFORM_LOG(Info, "* Initialise: " << getClassTypeName());

		mVertexFormat = MyGUI::VertexColourType::ColourARGB;

		memset(&mInfo, 0, sizeof(mInfo));

		setViewSize(Engine::Instance()->GetDeviceProperty()->Width,
					Engine::Instance()->GetDeviceProperty()->Height);
	
		mUpdate = false;

		mShaderLib = ShaderLibManager::Instance()->LoadShaderLib("Shaders\\MGUI.ShaderLib", "Shaders\\MGUI.ShaderLib");
		d_assert (mShaderLib);
		mDefaultTech = mShaderLib->GetTechnique("MGUI_Default");
		d_assert (mDefaultTech);

		mVertexDecl = VideoBufferManager::Instance()->CreateVertexDeclaration();

		mVertexDecl->AddElement(0, 0, DT_FLOAT3, DU_POSITION, 0);
		mVertexDecl->AddElement(0, 12, DT_COLOR, DU_COLOR, 0);
		mVertexDecl->AddElement(0, 16, DT_FLOAT2, DU_TEXCOORD, 0);
		mVertexDecl->Init();

		MYGUI_PLATFORM_LOG(Info, getClassTypeName() << " successfully initialized");
		mIsInitialise = true;
	}
示例#11
0
  void
  worker_thread_type::
start_run__from_master_thread
 (  input_params_type const &  input_params
  , sheet_type        const &  src_sheet
  , sheet_type              &  trg_sheet
  , sheet_type              &  extra_sheet
 )
  // Start running the worker thread.
  // The worker thread will signal when it is done.
{
    // This is called from the master thread.
    d_assert( currentThread( ) != this);

    // This is only called if we are not running.
    d_assert( 0 == p_src_sheet_  );
    d_assert( 0 == p_trg_sheet_  );
    d_assert( 0 == p_extra_sheet_);

    // Setup the params for the solver.
    input_params_  = input_params  ;
    p_src_sheet_   = & src_sheet   ;
    p_trg_sheet_   = & trg_sheet   ;
    p_extra_sheet_ = & extra_sheet ;

    // This signal should be picked up by the worker thread.
    emit start__master_to_worker( );
}
示例#12
0
	void Water::Load(const char * source)
	{
		DataStreamPtr stream = ResourceManager::Instance()->OpenResource(source);

		if (stream == NULL)
			return ;

		int Magic, Version;

		stream->Read(&Magic, sizeof(int));
		stream->Read(&Version, sizeof(int));

		d_assert (Magic == K_Magic);

		d_assert (Version == 0);

		if (Version == 0)
		{
			int sizeX, sizeZ;

			stream->Read(&sizeX, sizeof(int));
			stream->Read(&sizeZ, sizeof(int));

			d_assert (sizeX == mSizeX && sizeZ == mSizeZ);

			stream->Read(&mHeight, sizeof(float));

			stream->Read(mData, sizeX * sizeZ);
		}

		_initBlock();
	}
示例#13
0
std::pair<byte*, size_t> memory_sub_session::add_merge_remove_free_small_chunk(byte* p, size_t bytes)
{
    std::pair<byte*, std::pair<size_t, int> > chunk_alloc = free_small_chunk_alloc(p);

    size_t remainder_size = bytes;
    byte* remainder_pointer = p;

    if (!free_small_chunks.empty())
    {
        // adding and merging free space
        std::map<byte*, size_t>::iterator next = free_small_chunks.upper_bound(remainder_pointer);

        if (next != free_small_chunks.begin())
        {
            std::map<byte*, size_t>::iterator previous = next;
            --previous;

            if (previous->first >= chunk_alloc.first)
            {
                d_assert(remainder_pointer > previous->first);

                const size_t diff = remainder_pointer - previous->first;
                d_assert(diff >= previous->second);

                if (diff == previous->second)
                {
                    remainder_pointer = previous->first;
                    remainder_size += previous->second;

                    free_small_chunks_inv.erase(std::make_pair(previous->second, previous->first));
                    free_small_chunks.erase(previous);
                    parent->ram_allocated_bytes -= free_small_chunk_size;
                    parent->total_allocated_bytes -= free_small_chunk_size;

                    next = free_small_chunks.upper_bound(remainder_pointer);
                }
            }
        }

        if (next != free_small_chunks.end() && remainder_size != chunk_alloc.second.first)
        {
            d_assert(next->first > remainder_pointer);

            const size_t diff = next->first - remainder_pointer;

            if (diff == remainder_size)
            {
                remainder_size += next->second;

                free_small_chunks_inv.erase(std::make_pair(next->second, next->first));
                free_small_chunks.erase(next);
                parent->ram_allocated_bytes -= free_small_chunk_size;
                parent->total_allocated_bytes -= free_small_chunk_size;
            }
        }
    }

    return std::make_pair(remainder_pointer, remainder_size);
}
示例#14
0
  /* static */
  int
  pack_range_steps_holder::
convert_linear_pack_to_ui( int i_linear_pack)
  {
    d_assert( is_valid_linear_pack( i_linear_pack));
    int const i_ui = i_linear_pack * i_linear_to_ui_expand_factor;
    d_assert( is_valid_ui( i_ui));
    return i_ui;
  }
示例#15
0
void memory_sub_session::remove_small_alloc(byte* p)
{
    std::set<std::pair<byte*, size_t> >::const_iterator i = small_allocs.upper_bound(std::make_pair(p, 0));
    d_assert(i != small_allocs.end());
    d_assert(i->first == p);

    small_allocs.erase(i);
    parent->ram_allocated_bytes -= small_alloc_size;
    parent->total_allocated_bytes -= small_alloc_size;
}
示例#16
0
void SetupTextBox(MGUI::Layout * layout, const uchar_t * caption, const String & parentName)
{
	d_assert (layout != NULL);

	MGUI::Widget * parentWidget = layout->GetChild(parentName.c_str());
	d_assert (parentWidget != NULL);

	MGUI::TextBox * textBox = new MGUI::TextBox(NULL, parentWidget);
	textBox->SetAlign(MGUI::eAlign::LEFT | MGUI::eAlign::V_CENTER);
	textBox->SetCaption(caption);
}
示例#17
0
  /* static */
  double
  pack_range_steps_holder::
convert_ui_to_log_pack( int i_ui)
{
    d_assert( (-10000 <= i_ui) && (i_ui <= 10000)); // is_valid_ui_for_log_pack
    // std::exp(..) calcs the "natural" exponential.
    double const d_linear_pack = convert_ui_to_linear_pack( i_ui);
    double const d_log_pack = std::exp( d_linear_pack);
    d_assert( (0.0001 <= d_log_pack) && (d_log_pack <= 10000.0)); // is_valid_log_pack
    return d_log_pack;
}
示例#18
0
  /* destructor */
  worker_thread_type::
~worker_thread_type( )
{
    // Which thread runs the destructor?
    // d_assert( currentThread( ) != this) ?

    // We should not be in the middle of a run.
    d_assert( 0 == p_src_sheet_  );
    d_assert( 0 == p_trg_sheet_  );
    d_assert( 0 == p_extra_sheet_);
}
示例#19
0
  /* slot (protected) */
  void
  double_slide_holder::
intercept__has_changed__steps( inner_value_type /* inner_ss */, inner_value_type /* inner_ps */)
{
    // We should be the only ones setting these inner values.
    d_assert( is_setting( ));

    // Confirm that everything looks right.
    d_assert( is_valid( ));

    // Our setter will emit this signal later.
}
示例#20
0
  /* static */
  double
  pack_range_steps_holder::
convert_ui_to_linear_pack( int i_ui)
  //
  // Changes an integer to a double 1000 times smaller.
  // Used when you need a big integer for a UI widget, but you store a small double.
  {
    d_assert( is_valid_ui( i_ui));
    double const d_linear_pack = static_cast< double >( i_ui) * d_ui_to_linear_squeeze_factor;
    d_assert( is_valid_linear_pack( d_linear_pack));
    return d_linear_pack;
  }
示例#21
0
d_define_method(illuminable_bitmap, set_light_mask)(struct s_object *self, struct s_object *drawable_mask, enum e_illuminable_bitmap_sides side) {
  d_using(illuminable_bitmap);
  double mask_width, mask_height, image_width, image_height;
  if (illuminable_bitmap_attributes->drawable_mask[side])
    d_delete(illuminable_bitmap_attributes->drawable_mask[side]);
  illuminable_bitmap_attributes->drawable_mask[side] = d_retain(drawable_mask);
  d_call(illuminable_bitmap_attributes->drawable_mask[side], m_drawable_set_blend, e_drawable_blend_add);
  d_call(illuminable_bitmap_attributes->drawable_mask[side], m_drawable_get_dimension, &mask_width, &mask_height);
  d_call(self, m_drawable_get_dimension, &image_width, &image_height);
  d_assert((image_width == mask_width));
  d_assert((image_height == mask_height));
  return self;
}
示例#22
0
  void
  int_range_steps_holder::
detach( QAbstractSlider * p_slider)
{
    d_assert( p_slider);
    d_assert( is_valid( ));
    d_assert( attached_widgets_.contains( p_slider));

    d_verify( disconnect( p_slider, SIGNAL( valueChanged( int)), this, SLOT( set_value( int))));
    d_verify( disconnect( p_slider, SIGNAL( destroyed( QObject *)), this, SLOT( before_dtor( QObject *))));
    d_verify( 1 == attached_widgets_.removeAll( p_slider));

    d_assert( ! attached_widgets_.contains( p_slider));
    d_assert( is_valid( ));
}
示例#23
0
  /* ctor */
  double_slide_holder::
double_slide_holder
 (  QObject *   p_parent
  , value_type  outer_init  // = 0.0
  , value_type  outer_lo    // = -1.0
  , value_type  outer_hi    // = +1.0
 )
  : holder_base_type( p_parent)
  , p_inner_holder_ ( 0)
  , outer_lo_       ( 0)
  , inner_to_outer_ ( 0)
  , outer_to_inner_ ( 0)
{
    setup_conversions( outer_lo, outer_hi);

    // Now that conversions are set up, create the inner holder.
    // Should we use the global lo/hi limits, or the calculated limits? We'll use the
    // calculated limits for now.
    p_inner_holder_ =
        new inner_holder_type
             (  this
              , convert_outer_to_inner( outer_init)
              , convert_outer_to_inner( outer_lo)
              , convert_outer_to_inner( outer_hi)
             );
    d_assert( p_inner_holder_);

    // Relay all the signals from the inner holder.
    d_verify( connect(
        p_inner_holder_, SIGNAL( has_changed( )),
        this, SLOT( intercept__has_changed( ))
    ));
    d_verify( connect(
        p_inner_holder_, SIGNAL( has_changed( int)),
        this, SLOT( intercept__has_changed( int))
    ));
    d_verify( connect(
        p_inner_holder_, SIGNAL( has_changed__range( int, int)),
        this, SLOT( intercept__has_changed__range( int, int))
    ));
    d_verify( connect(
        p_inner_holder_, SIGNAL( has_changed__steps( int, int)),
        this, SLOT( intercept__has_changed__steps( int, int))
    ));

    // Should always be true when outside class methods.
    d_assert( is_valid( ));
}
示例#24
0
	void NullTexture::_load(DataStreamPtr stream)
	{
		if (mLoadState != Resource::LOADING)
			return ;

		if (stream == NULL)
		{
			d_log("!: Load texture '%s' failed.", mSourceName.c_str());
			return ;
		}

		d_assert (mPixelData == NULL && mLockFlag == 0);

		Image image;
		if (IMG_Load(image, stream))
		{
			mPixelData = image.pixels;
			mWidth = image.width;
			mHeight = image.height;
			mFormat = image.format;
			mMipmaps = 1;
		}
		else
		{
			d_log ("?: image '%s' load failed.", mSourceName.c_str());
		}
	}
示例#25
0
TypeEd_ImageBox::TypeEd_ImageBox(MGUI::Widget * widget, MGUI::Widget * panel)
{
	d_assert (TYPE_OF(MGUI::ImageBox, widget));

	mImageBox = (MGUI::ImageBox *)widget;

	float top = 0;
	const float K_Space = 8;

	mLabel_Image = new MGUI::Label(NULL, panel);
	mLabel_Image->SetCaption(L"Image:");
	mLabel_Image->SetRect(0, top, 64, 24);

	mEditBox_Image = new MGUI::EditBox(AllLookFeel::Instance()->GetEditBox(), panel);
	mEditBox_Image->SetRect(80, top, 162, 24);

	top += 24 + K_Space;

	mLabel_UVRect = new MGUI::Label(NULL, panel);
	mLabel_UVRect->SetCaption(L"UVRect");
	mLabel_UVRect->SetRect(0, top, 162, 24);

	mEditBox_UVRect = new MGUI::EditBox(AllLookFeel::Instance()->GetEditBox(), panel);
	mEditBox_UVRect->SetRect(80, top, 162, 24);

	top += 24 + K_Space;

	// Init
	mEditBox_Image->SetCaption(mImageBox->GetSkin() != NULL ? mImageBox->GetSkin()->GetName().c_wstr() : L"");

	mEditBox_UVRect->SetCaption(mImageBox->GetUVRect().ToString().c_wstr());

	mEditBox_Image->E_KeyLostFocus += new cListener1<TypeEd_ImageBox, const MGUI::FocusEvent *>(this, &TypeEd_ImageBox::OnImageChanged);
	mEditBox_UVRect->E_KeyLostFocus += new cListener1<TypeEd_ImageBox, const MGUI::FocusEvent *>(this, &TypeEd_ImageBox::OnUVRectChanged);
}
示例#26
0
FileStream::FileStream(const TString128 & file)
{
    mData = NULL;
    mFile.Open(file.c_str(), OM_READ_BINARY);

    d_assert (mFile.IsOpen());
}
示例#27
0
  /* overridden virtual */
  void
  int_animator_type::
wrap_to_max( )
{
    d_assert( p_holder_);
    p_holder_->wrap_to_max( );
}
示例#28
0
  /* overridden virtual */
  bool
  int_animator_type::
is_bumping_max( )
{
    d_assert( p_holder_);
    return p_holder_->is_bumping_max( );
}
示例#29
0
  /* overridden virtual */
  holder_base_type *
  int_animator_type::
get_animated( ) const
{
    d_assert( p_holder_);
    return p_holder_;
}
示例#30
0
void memory_session::init(bool autobegin)
{
    memory_manager::instance->reserve_total_bytes(total_limit_bytes, &unfreeze_condition, 0, 0);

    try
    {
        memory_manager::instance->reserve_ram_bytes(ram_limit_bytes, &unfreeze_condition, 0, total_limit_bytes);
    }
    catch (...)
    {
        memory_manager::instance->free_total_bytes(total_limit_bytes);
        throw;
    }

    d_assert(unfrozen_threads_count == UNINITIALIZED, "Double initialization of memory session");
    unfrozen_threads_count = NOTSTARTED;

    if (autobegin)
    {
        try
        {
            begin();
        }
        catch (...)
        {
            memory_manager::instance->free_total_bytes(total_limit_bytes);
            memory_manager::instance->free_ram_bytes(ram_limit_bytes);
            unfrozen_threads_count = UNINITIALIZED;
            throw;
        }
    }
}