当前位置: 首页>>代码示例>>C++>>正文


C++ deleter函数代码示例

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


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

示例1: main

int main(int argc, const char *argv[]) {
    enablePool(RPool);
    ComplexTest();


    // [ ] ,  [ [ [ ] ] ],  [ [ ] [] [ ] ]
    const RString *source = RS(" ++++++++++ [ >+++++++>++++++++++>+++>+<<<<- ] >++\n"
                                  " .>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.\n"
                                  " ------.--------.>+.>.");

    RVirtualFunction *function = c(RVirtualFunction)(nil);
    function->name = RSC("Hello");
    function->masterRDataObject = makeRDataAllocated(5);
    function->masterRDataObject->data[0] = r_addition;
    function->masterRDataObject->data[1] = 0x01;

    function->masterRDataObject->data[2] = r_addition;
    function->masterRDataObject->data[3] = 0x23;

    function->masterRDataObject->data[4] = r_end;

    // brainfuck hard(with [, ]) hello world on RVM
//    RVirtualFunction *function = $(RVC, m(createFunctionFromBrainFuckSourceCode, RVirtualCompiler)), source );

    p(RVirtualFunction)(function);

    executeRay(function);

    deleter(function, RVirtualFunction);
    deleter(RVM, RVirtualMachine);
    deleter(RVC, RVirtualCompiler);

    endRay();
}
开发者ID:kojiba,项目名称:RayLanguage,代码行数:34,代码来源:main.c

示例2: Run

	void Run(SMInvoker &invoker, bigtime_t targetUnblock,
			 bigtime_t targetReply, status_t result, bool deliverySuccess,
			 bool replySuccess, bigtime_t duration)
	{
//printf("SMTester::Run(%lld, %lld, %lx, %d, %d, %lld)\n", targetUnblock,
//targetReply, result, deliverySuccess, replySuccess, duration);
		enum { JITTER = 10000 };
		enum { SETUP_LATENCY = 100000 };
		enum { DELIVERY_LATENCY = 10000 };
		enum { TARGET_HEAD_START = 1000 };
		if (targetUnblock == 0)
			targetUnblock = -TARGET_HEAD_START;
		// create the target
		SMTarget *target = NULL;
		switch (fTargetKind) {
			case TARGET_UNINITIALIZED:
				target = new SMTarget;
				break;
			case TARGET_LOCAL_PREFERRED:
				target = new LocalSMTarget(true);
				break;
			case TARGET_LOCAL_SPECIFIC:
				target = new LocalSMTarget(false);
				break;
			case TARGET_REMOTE_PREFERRED:
				target = new RemoteSMTarget(true);
				break;
			case TARGET_REMOTE_SPECIFIC:
				target = new RemoteSMTarget(false);
				break;
		}
		AutoDeleter<SMTarget> deleter(target);
		// create the reply target
		SMReplyTarget replyTarget;
		// init the target and send the message
		BHandler *replyHandler = replyTarget.Handler();
		BMessenger replyMessenger = replyTarget.Messenger();
		bigtime_t startTime = system_time() + SETUP_LATENCY;
		target->Init(startTime + targetUnblock, targetReply);
		BMessenger targetMessenger = target->Messenger();
		snooze_until(startTime, B_SYSTEM_TIMEBASE);
		status_t actualResult = invoker.Invoke(targetMessenger, replyHandler,
											   replyMessenger);
		bigtime_t actualDuration = system_time() - startTime;
//printf("duration: %lld vs %lld\n", actualDuration, duration);
		// We need to wait for the reply, if reply mode is asynchronous.
		snooze_until(startTime + targetUnblock + targetReply
					 + 2 * DELIVERY_LATENCY, B_SYSTEM_TIMEBASE);
		bool actualReplySuccess = invoker.ReplySuccess();
		if (!invoker.DirectReply())
			actualReplySuccess = replyTarget.ReplySuccess();
		// check the results
if (actualResult != result)
printf("result: %lx vs %lx\n", actualResult, result);
		CHK(actualResult == result);
		CHK(target->DeliverySuccess() == deliverySuccess);
		CHK(actualReplySuccess == replySuccess);
		CHK(actualDuration > duration - JITTER
			&& actualDuration < duration + JITTER);
	}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:60,代码来源:SendMessageTester.cpp

示例3: resultDateInJson

std::string resultDateInJson(const UDate& date)
{
    UErrorCode status = U_ZERO_ERROR;
    Calendar* cal = Calendar::createInstance(status);
    if (!cal) {
        slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::resultInJson: failed to create Calendar instance: %d",
                status);
        return errorInJson(UNKNOWN_ERROR, "Failed to create Calendar instance!");
    }
    std::auto_ptr<Calendar> deleter(cal);

    cal->setTime(date, status);
    if (status != U_ZERO_ERROR && status != U_ERROR_WARNING_START) {
        slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::resultInJson: failed to setTime: %d",
                status);
        return errorInJson(UNKNOWN_ERROR, "Failed to set Calendar time!");
    }

    Json::Value result;
    result["year"] = cal->get(UCAL_YEAR, status);
    result["month"] = cal->get(UCAL_MONTH, status);
    result["day"] = cal->get(UCAL_DAY_OF_MONTH, status);
    result["hour"] = cal->get(UCAL_HOUR, status);
    result["minute"] = cal->get(UCAL_MINUTE, status);
    result["second"] = cal->get(UCAL_SECOND, status);
    result["millisecond"] = cal->get(UCAL_MILLISECOND, status);

    Json::Value root;
    root["result"] = result;

    Json::FastWriter writer;
    return writer.write(root);
}
开发者ID:ElNinjaGaiden,项目名称:GoogleMapsCordovaTest,代码行数:33,代码来源:globalization_ndk.cpp

示例4: dense_region

RegionSnapshot dense_region(
  RegionType region_type,
  void *start_addr, void* permanent_addr, size_t size)
{
  simgrid::mc::RegionSnapshot::flat_data_ptr data;
  if (!_sg_mc_ksm)
    data = simgrid::mc::RegionSnapshot::flat_data_ptr((char*) malloc(size));
  else {
    char* ptr = (char*) mmap(nullptr, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, -1, 0);
    if (ptr == MAP_FAILED)
      throw std::bad_alloc();
    simgrid::mc::data_deleter deleter(
      simgrid::mc::data_deleter::Munmap, size);
    data = simgrid::mc::RegionSnapshot::flat_data_ptr(ptr, deleter);
  }
  mc_model_checker->process().read_bytes(data.get(), size,
    remote(permanent_addr),
    simgrid::mc::ProcessIndexDisabled);
  if (_sg_mc_ksm)
    // Mark the region as mergeable *after* we have written into it.
    // There no point to let KSM do the hard work before that.
    madvise(data.get(), size, MADV_MERGEABLE);

  simgrid::mc::RegionSnapshot region(
    region_type, start_addr, permanent_addr, size);
  region.flat_data(std::move(data));

  XBT_DEBUG("New region : type : %s, data : %p (real addr %p), size : %zu",
            to_cstr(region_type), region.flat_data(), permanent_addr, size);
  return std::move(region);
}
开发者ID:apargupta,项目名称:simgrid,代码行数:31,代码来源:RegionSnapshot.cpp

示例5: main

int main()
{
    {
        boost::shared_array<X> p;

        BOOST_TEST(boost::get_deleter<void>(p) == 0);
        BOOST_TEST(boost::get_deleter<void const>(p) == 0);
        BOOST_TEST(boost::get_deleter<int>(p) == 0);
        BOOST_TEST(boost::get_deleter<int const>(p) == 0);
        BOOST_TEST(boost::get_deleter<X>(p) == 0);
        BOOST_TEST(boost::get_deleter<X const>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter const>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter2>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter2 const>(p) == 0);
    }

    {
        boost::shared_array<X> p(new X[1]);

        BOOST_TEST(boost::get_deleter<void>(p) == 0);
        BOOST_TEST(boost::get_deleter<void const>(p) == 0);
        BOOST_TEST(boost::get_deleter<int>(p) == 0);
        BOOST_TEST(boost::get_deleter<int const>(p) == 0);
        BOOST_TEST(boost::get_deleter<X>(p) == 0);
        BOOST_TEST(boost::get_deleter<X const>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter const>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter2>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter2 const>(p) == 0);
    }

    {
        X x[1];
        boost::shared_array<X> p(x, deleter());

        BOOST_TEST(boost::get_deleter<void>(p) == 0);
        BOOST_TEST(boost::get_deleter<void const>(p) == 0);
        BOOST_TEST(boost::get_deleter<int>(p) == 0);
        BOOST_TEST(boost::get_deleter<int const>(p) == 0);
        BOOST_TEST(boost::get_deleter<X>(p) == 0);
        BOOST_TEST(boost::get_deleter<X const>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter2>(p) == 0);
        BOOST_TEST(boost::get_deleter<deleter2 const>(p) == 0);

        deleter * q = boost::get_deleter<deleter>(p);

        BOOST_TEST(q != 0);
        BOOST_TEST(q->data == 0);

        q->data = 17041;

        deleter const * r = boost::get_deleter<deleter const>(p);

        BOOST_TEST(r == q);
        BOOST_TEST(r->data == 17041);
    }

    return boost::report_errors();
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:60,代码来源:get_deleter_array_test.cpp

示例6: make_pointer

 inline result_type make_pointer(value_type* ptr, boost::non_type<
     factory_alloc_propagation,factory_alloc_for_pointee_and_deleter>)
 const
 {
     return result_type(ptr,deleter(this->get_allocator()),
         this->get_allocator());
 }
开发者ID:00liujj,项目名称:dealii,代码行数:7,代码来源:factory.hpp

示例7: data

status_t
BPhotoContactField::Unflatten(type_code code,
	const void* buffer,	ssize_t size)
{
	BMemoryIO data(buffer, size);
	status_t ret = BContactField::Unflatten(code, &data);
	if (ret != B_OK)
		return ret;

	BMessage msg;
	ssize_t destSize;
	data.Read(&destSize, sizeof(destSize));

	if (destSize < 1) {
		fBitmap = NULL;
		return B_OK;
	}

	void* buf = malloc(destSize);
	MemoryDeleter deleter(buf);
	data.Read(buf, destSize);

	BMemoryIO dest(buf, destSize);
	msg.Unflatten(&dest);

	fBitmap = new BBitmap(&msg);

	return fBitmap->InitCheck();
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:29,代码来源:ContactField.cpp

示例8: deleter

    void AudioOutputDeviceManager::removeDeviceEventProc(
        int                                                 _card
        , std::multimap< int, const AudioOutputDevice * > & _devices
    )
    {
        auto    iterators = _devices.equal_range( _card );

        if( iterators.first == _devices.end() ) {
            return;
        }

        DevicesDeleter  deleter(
            _devices
            , iterators
        );

        std::for_each(
            iterators.first
            , iterators.second
            , [
                this
            ]
            (
                std::pair< const int, const AudioOutputDevice * > & _pair
            )
            {
                const auto  DEVICE = _pair.second;

                this->callDisconnectEventHandler(
                    *DEVICE
                );
            }
        );
    }
开发者ID:tktk,项目名称:dp.old,代码行数:34,代码来源:audiooutputdevicemanager.cpp

示例9: makeRBufferOptions

RBuffer* makeRBufferOptions(size_t startSize, size_t objectCount) {
    RBuffer *object = allocator(RBuffer);
    if(object != nil) {
        // allocation of buffer
        master(object, RData) = makeRDataBytes(arrayAllocator(byte, startSize), startSize);
        if(master(object, RData) != nil) {

            // allocation of sizes array
            object->sizesArray = arrayAllocator(RRange, objectCount);

            if(object->sizesArray  != nil) {
                object->classId     = registerClassOnce(toString(RBuffer));
                object->freePlaces  = objectCount;
                object->count       = 0;
                object->totalPlaced = 0;
#ifdef RAY_BUFFER_THREAD_SAFE
                mutexWithType(&object->mutex, RMutexRecursive);
#endif
            } else {
                RError("RBuffer. Allocation of sizes array failed.", object);
                deleter(master(object, RData), RData);
            }
        } else {
            RError("RBuffer. Allocation of master RData failed.", object);
            deallocator(object);
            object = nil;
        }
    }
    return object;
}
开发者ID:tml,项目名称:RayLanguage,代码行数:30,代码来源:RBuffer.c

示例10: deleter

Session::Session(S_Connection conn, sr_datastore_t datastore, const sr_sess_options_t opts, \
                 const char *user_name)
{
    int ret;
    _opts = opts;
    _datastore = datastore;
    _conn = nullptr;
    _sess = nullptr;
    S_Deleter deleter(new Deleter(_sess));

    if (user_name == nullptr) {
        /* start session */
        ret = sr_session_start(conn->_conn, _datastore, _opts, &_sess);
        if (SR_ERR_OK != ret) {
            goto cleanup;
        }
    } else {
        /* start session */
        ret = sr_session_start_user(conn->_conn, user_name, _datastore, _opts, &_sess);
        if (SR_ERR_OK != ret) {
            goto cleanup;
        }
    }

    _deleter = deleter;
    _conn = conn;
    return;

cleanup:
    throw_exception(ret);
}
开发者ID:qmm161,项目名称:sysrepo,代码行数:31,代码来源:Session.cpp

示例11: makeShared

std::shared_ptr<T> makeShared(Args&&... args) {
    return std::shared_ptr<T>(new T(std::forward<Args>(args)...),
                              [](T* instance) {
                                  auto&& deleter = internal::getDeleter<T>();
                                  deleter(instance);
                              });
}
开发者ID:enrevol,项目名称:ee-x,代码行数:7,代码来源:SharedPtrUtils.hpp

示例12: BMessage

void
TBarWindow::AddItem(BMessage* message)
{
	DeskbarShelf shelf = B_DESKBAR_TRAY;
	entry_ref ref;
	int32 id = 999;
	BMessage reply;
	status_t err = B_ERROR;

	BMessage* archivedView = new BMessage();
	ObjectDeleter<BMessage> deleter(archivedView);
	if (message->FindMessage("view", archivedView) == B_OK) {
#if SHELF_AWARE
		message->FindInt32("shelf", &shelf);
#endif
		err = fBarView->AddItem(archivedView, shelf, &id);
		if (err == B_OK) {
			// Detach the deleter since AddReplicant is taking ownership
			// on success. This should be changed on server side.
			deleter.Detach();
		}
	} else if (message->FindRef("addon", &ref) == B_OK) {
		BEntry entry(&ref);
		err = entry.InitCheck();
		if (err == B_OK)
			err = fBarView->AddItem(&entry, shelf, &id);
	}

	if (err == B_OK)
		reply.AddInt32("id", id);
	else
		reply.AddInt32("error", err);

	message->SendReply(&reply);
}
开发者ID:looncraz,项目名称:haiku,代码行数:35,代码来源:BarWindow.cpp

示例13: deleter

 ~untyped_heap_storage()
 {
     if (pointer)
     {
         deleter();
     }
 }
开发者ID:podusowski,项目名称:sandbox_duck_typing,代码行数:7,代码来源:untyped_heap_storage.hpp

示例14: main

int main()
{
    boost::shared_ptr<X> p( new X, deleter() );

    test_get_deleter( p );

    return boost::report_errors();
}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:8,代码来源:get_deleter_test2.cpp

示例15: B_BENDIAN_TO_HOST_INT16

void
AHCIPort::ScsiUnmap(scsi_ccb* request, scsi_unmap_parameter_list* unmapBlocks)
{
	// Determine how many ranges we'll need
	// We assume that the SCSI unmap ranges cannot be merged together
	uint32 scsiRangeCount = B_BENDIAN_TO_HOST_INT16(
		unmapBlocks->block_data_length) / sizeof(scsi_unmap_block_descriptor);
	uint32 lbaRangeCount = 0;
	for (uint32 i = 0; i < scsiRangeCount; i++) {
		lbaRangeCount += ((uint32)B_BENDIAN_TO_HOST_INT32(
			unmapBlocks->blocks[i].block_count) + 65534) / 65535;
	}

	uint32 lbaRangesSize = lbaRangeCount * sizeof(uint64);
	uint64* lbaRanges = (uint64*)malloc(lbaRangesSize);
	if (lbaRanges == NULL) {
		TRACE("out of memory when allocating %" B_PRIu32 " unmap ranges\n",
			lbaRangeCount);
		request->subsys_status = SCSI_REQ_ABORTED;
		gSCSI->finished(request, 1);
		return;
	}

	MemoryDeleter deleter(lbaRanges);

	for (uint32 i = 0, scsiIndex = 0; scsiIndex < scsiRangeCount; scsiIndex++) {
		uint64 lba = (uint64)B_BENDIAN_TO_HOST_INT64(
			unmapBlocks->blocks[scsiIndex].lba);
		uint64 blocksLeft = (uint32)B_BENDIAN_TO_HOST_INT32(
			unmapBlocks->blocks[scsiIndex].block_count);
		while (blocksLeft > 0) {
			uint16 blocks = blocksLeft > 65535 ? 65535 : (uint16)blocksLeft;
			lbaRanges[i++] = B_HOST_TO_LENDIAN_INT64(
				((uint64)blocks << 48) | lba);
			lba += blocks;
			blocksLeft -= blocks;
		}
	}

	sata_request sreq;
	sreq.SetATA48Command(ATA_COMMAND_DATA_SET_MANAGEMENT, 0,
		(lbaRangesSize + 511) / 512);
	sreq.SetFeature(1);
	sreq.SetData(lbaRanges, lbaRangesSize);

	ExecuteSataRequest(&sreq);
	sreq.WaitForCompletion();

	if ((sreq.CompletionStatus() & ATA_ERR) != 0) {
		TRACE("trim failed (%" B_PRIu32 " ranges)!\n", lbaRangeCount);
		request->subsys_status = SCSI_REQ_CMP_ERR;
	} else
		request->subsys_status = SCSI_REQ_CMP;

	request->data_resid = 0;
	request->device_status = SCSI_STATUS_GOOD;
	gSCSI->finished(request, 1);
}
开发者ID:DonCN,项目名称:haiku,代码行数:58,代码来源:ahci_port.cpp


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