当前位置:网站首页>Expansion of D @nogc
Expansion of D @nogc
2022-06-12 06:57:00 【fqbqrr】
import std.traits;
// Convert from a function or closure type `@nogc`
auto assumeNoGC(T) (T t) if (isFunctionPointer!T || isDelegate!T)
{
enum attrs = functionAttributes!T | FunctionAttribute.nogc;
return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t;
}
// Can't press `@nogc` Marker function , But you know you don't use garbage collection
void funcThatMightUseGC(int timeout)
{
if (unlikelyCondition(timeout))
throw new Exception(" Thrown ");
doMoreStuff();
}
void funcThatCantAffortGC() @nogc
{
// Call garbage collection with transformation closure .
assumeNoGC( (int timeout)
{
funcThatMightUseGC(timeout);
})(10000);
}
边栏推荐
- The second day of June training - string
- 六月集训 第五天——双指针
- Solution: content type 'application/x-www-form-urlencoded; charset=UTF-8‘ not supported
- Interview intelligence questions
- Set [list] to find out the subscript of repeated elements in the list (display the position of the subscript)
- CL210OpenStack操作的故障排除--章节实验
- The first day of June training - array
- Use ms17-010 Eternal Blue vulnerability to infiltrate win7 and establish a permanent back door
- 集合判断存在交集
- 网络丢包问题排查
猜你喜欢
![Leetcode: offer 60 Points of N dice [math + level DP + cumulative contribution]](/img/2b/41bd6a213892062f4c12721b5d4e8d.png)
Leetcode: offer 60 Points of N dice [math + level DP + cumulative contribution]
![leetcode:890. Find and replace mode [two dict records set]](/img/a8/e1ea743bbd8d2aca4de3e3ac3b4ac3.png)
leetcode:890. Find and replace mode [two dict records set]

I met 15 people recently and found that I couldn't answer the basic question of this test

库里扛起了勇士对凯尔特人的第四场

Jackson XML is directly converted to JSON without writing entity classes manually

How to build your own website (using the pagoda panel)

An error occurred while downloading the remote file The errormessage

Descscheduler secondary scheduling makes kubernetes load more balanced

leetcode:剑指 Offer 63. 股票的最大利润【记录前缀最小和 or 无脑线段树】

8. 表单标签
随机推荐
Computer composition and design work06 - based on MIPS
I met 15 people recently and found that I couldn't answer the basic question of this test
C language pointer
Tomato learning notes -seq2seq
Flink practice
Idea common shortcut keys
8 IO Library
d的扩大@nogc
Elegantly spliced XML
Unable to load bean of class marked with @configuration
Android studio uses database to realize login and registration interface function
Redis distributed lock
Matlab 6-DOF manipulator forward and inverse motion
PHP read / write cookie
Torch models trained in higher versions report errors in lower versions
集合判断存在交集
企业微信官方 加解密库 PHP7版本报错 mcrypt_module_open 未定义方法 并且被PHP抛弃 解决方法使用 openssl解决
【图像去噪】基于高斯滤波、均值滤波、中值滤波、双边滤波四种滤波实现椒盐噪声图像去噪附matlab代码
leetcode:890. Find and replace mode [two dict records set]
1.3-1.9 summary