apr::pool.3

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 3 代码 · 共 485 行 · 第 1/2 页

3
485
字号
If there is more than one callback registered (when\&\f(CW\*(C`cleanup_register\*(C'\fR is called more than once on the same pool object),the last registered callback will be executed first (\s-1LIFO\s0)..PPExamples:.PPNo arguments, using anon sub as a cleanup callback:.PP.Vb 1\&  $r\->pool\->cleanup_register(sub { warn "running cleanup" });.Ve.PPOne or more arguments using a cleanup code reference:.PP.Vb 7\&  $r\->pool\->cleanup_register(\e&cleanup, $r);\&  $r\->pool\->cleanup_register(\e&cleanup, [$r, $foo]);\&  sub cleanup {\&      my @args = (@_ && ref $_[0] eq ARRAY) ? @{ +shift } : shift;\&      my $r = shift @args;\&      warn "cleaning up";\&  }.Ve.PPNo arguments, using a function name as a cleanup callback:.PP.Vb 1\&  $r\->pool\->cleanup_register(\*(Aqfoo\*(Aq);.Ve.ie n .Sh """clear""".el .Sh "\f(CWclear\fP".IX Subsection "clear"Clear all memory in the pool and run all the registered cleanups. Thisalso destroys all sub-pools..PP.Vb 1\&  $pool\->clear();.Ve.ie n .IP "obj: $pool\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "obj: \f(CW$pool\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "obj: $pool ( APR::Pool object )"The pool to clear.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPThis method differs from \f(CW\*(C`destroy()\*(C'\fR in that it is notfreeing the previously allocated, but allows the pool to re-use it forthe future memory allocations..ie n .Sh """DESTROY""".el .Sh "\f(CWDESTROY\fP".IX Subsection "DESTROY"\&\f(CW\*(C`DESTROY\*(C'\fR is an alias to \f(CW\*(C`destroy\*(C'\fR. It's there sothat custom \f(CW\*(C`APR::Pool\*(C'\fR objects will get properly cleaned up, whenthe pool object goes out of scope. If you ever want to destroy an\&\f(CW\*(C`APR::Pool\*(C'\fR object before it goes out of scope, use\&\f(CW\*(C`destroy\*(C'\fR..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """destroy""".el .Sh "\f(CWdestroy\fP".IX Subsection "destroy"Destroy the pool..PP.Vb 1\&  $pool\->destroy();.Ve.ie n .IP "obj: $pool\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "obj: \f(CW$pool\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "obj: $pool ( APR::Pool object )"The pool to destroy.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPThis method takes a similar action to \f(CW\*(C`clear()\*(C'\fR and thenfrees all the memory..ie n .Sh """is_ancestor""".el .Sh "\f(CWis_ancestor\fP".IX Subsection "is_ancestor"Determine if pool a is an ancestor of pool b.PP.Vb 1\&  $ret = $pool_a\->is_ancestor($pool_b);.Ve.ie n .IP "obj: $pool_a\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "obj: \f(CW$pool_a\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "obj: $pool_a ( APR::Pool object )"The pool to search.ie n .IP "arg1: $pool_b\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "arg1: \f(CW$pool_b\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "arg1: $pool_b ( APR::Pool object )"The pool to search for.ie n .IP "ret: $ret ( integer )" 4.el .IP "ret: \f(CW$ret\fR ( integer )" 4.IX Item "ret: $ret ( integer )"True if \f(CW$pool_a\fR is an ancestor of \f(CW$pool_b\fR..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPFor example create a sub-pool of a given pool and check that the poolis an ancestor of that sub-pool:.PP.Vb 4\&  use APR::Pool ();\&  my $pp = $r\->pool;\&  my $sp = $pp\->new();\&  $pp\->is_ancestor($sp) or die "Don\*(Aqt mess with genes!";.Ve.ie n .Sh """new""".el .Sh "\f(CWnew\fP".IX Subsection "new"Create a new sub-pool.PP.Vb 2\&  my $pool_child = $pool_parent\->new;\&  my $pool_child = APR::Pool\->new;.Ve.ie n .IP "obj: $pool_parent\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "obj: \f(CW$pool_parent\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "obj: $pool_parent ( APR::Pool object )"The parent pool..SpIf you don't have a parent pool to create the sub-pool from, you canuse this object method as a class method, in which case the sub-poolwill be created from the global pool:.Sp.Vb 1\&  my $pool_child = APR::Pool\->new;.Ve.ie n .IP "ret: $pool_child\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "ret: \f(CW$pool_child\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "ret: $pool_child ( APR::Pool object )"The child sub-pool.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """parent_get""".el .Sh "\f(CWparent_get\fP".IX Subsection "parent_get"Get the parent pool.PP.Vb 1\&  $parent_pool = $child_pool\->parent_get();.Ve.ie n .IP "obj: $child_pool\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "obj: \f(CW$child_pool\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "obj: $child_pool ( APR::Pool object )"the child pool.ie n .IP "ret: $parent_pool\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "ret: \f(CW$parent_pool\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "ret: $parent_pool ( APR::Pool object )"the parent pool. \f(CW\*(C`undef\*(C'\fR if there is no parent pool (which is thecase for the top-most global pool)..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPExample: Calculate how big is the pool's ancestry:.PP.Vb 10\&  use APR::Pool ();\&  sub ancestry_count {\&      my $child = shift;\&      my $gen = 0;\&      while (my $parent = $child\->parent_get) {\&          $gen++;\&          $child = $parent;\&      }\&      return $gen;\&  }.Ve.ie n .Sh """tag""".el .Sh "\f(CWtag\fP".IX Subsection "tag"Tag a pool (give it a name).PP.Vb 1\&  $pool\->tag($tag);.Ve.ie n .IP "obj: $pool\fR ( \f(CW""APR::Pool object"" )" 4.el .IP "obj: \f(CW$pool\fR ( \f(CWAPR::Pool object\fR )" 4.IX Item "obj: $pool ( APR::Pool object )"The pool to tag.ie n .IP "arg1: $tag ( string )" 4.el .IP "arg1: \f(CW$tag\fR ( string )" 4.IX Item "arg1: $tag ( string )"The tag (some unique string).IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPEach pool can be tagged with a unique label. This can prove usefulwhen doing low level apr_pool C tracing (when apr is compiled with\&\f(CW\*(C`\-DAPR_POOL_DEBUG\*(C'\fR). It allows you to \fIgrep\fR\|(1) for the tag you haveset, to single out the traces relevant to you..PPThough there is no way to get read the tag value, since \s-1APR\s0 doesn'tprovide such an accessor method..SH "Unsupported API".IX Header "Unsupported API"\&\f(CW\*(C`APR::Pool\*(C'\fR also provides auto-generated Perl interface for a fewother methods which aren't tested at the moment and therefore their\&\s-1API\s0 is a subject to change. These methods will be finalized later as aneed arises. If you want to rely on any of the following methodsplease contact the the mod_perl development mailinglist so we can help each other take the steps necessaryto shift the method to an officially supported \s-1API\s0..ie n .Sh """cleanup_for_exec""".el .Sh "\f(CWcleanup_for_exec\fP".IX Subsection "cleanup_for_exec"\&\s-1META:\s0 Autogenerated \- needs to be reviewed/completed.PPPreparing for \fIexec()\fR \-\-\- close files, etc., but *don't* flush I/Obuffers, *don't* wait for subprocesses, and *don't* free any memory.Run all of the child_cleanups, so that any unnecessary files areclosed because we are about to exec a new program.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: subject to change" 4.IX Item "since: subject to change".PD.SH "See Also".IX Header "See Also"mod_perl 2.0 documentation..SH "Copyright".IX Header "Copyright"mod_perl 2.0 and its core modules are copyrighted underThe Apache Software License, Version 2.0..SH "Authors".IX Header "Authors"The mod_perl development team and numerouscontributors.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?