// 文件:glibc/rt/aio_misc.c
/* User optimization. */
void
__aio_init (const struct aioinit *init)
{
/* Get the mutex. */
__pthread_mutex_lock (&__aio_requests_mutex);
/* Only allow writing new values if the table is not yet allocated. */
if (pool == NULL)
{
optim.aio_threads = init->aio_threads < 1 ? 1 : init->aio_threads;
assert (powerof2 (ENTRIES_PER_ROW));
optim.aio_num = (init->aio_num < ENTRIES_PER_ROW
? ENTRIES_PER_ROW
: init->aio_num & ~(ENTRIES_PER_ROW - 1));
}
if (init->aio_idle_time != 0)
optim.aio_idle_time = init->aio_idle_time;
/* Release the mutex. */
__pthread_mutex_unlock (&__aio_requests_mutex);
}
aio_threads 该字段指定可以使用的最大工作线程数 实施。如果未完成的 I/O 操作数量超过此值 limit,那么多余的操作将排队,直到工作线程变得 自由的。如果该字段指定的值小于 1,则使用值 1。
默认值为 20。
然后我很困惑地寻找 glibc 源代码中定义
aio_threads
的位置,但在那里什么也没找到。 __aio_init()
中的参数是一个const struct aioinit *
,我认为必须定义一些const struct aioinit
对象。但我失败了。
它是这里称为optim的数据结构的成员