File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -134,15 +134,20 @@ sub new {
134134 my %options = @_ ;
135135
136136 my $max_memory = $options {max_memory } || 0;
137+ my $timeout = $options {timeout } || 0;
138+
139+ if ($timeout ){
140+ croak " timeout option must be a number" if !JavaScript::Duktape::Vm::duk_sv_is_number( $timeout );
141+ }
137142
138143 if ( $max_memory ){
139- croak " max_memory option should be a number" if !JavaScript::Duktape::Vm::duk_sv_is_number( $max_memory );
144+ croak " max_memory option must be a number" if !JavaScript::Duktape::Vm::duk_sv_is_number( $max_memory );
140145 croak " max_memory must be at least 256k (256 * 1024)" if $max_memory < 256 * 1024;
141146 }
142147
143148 my $self = bless {}, $class ;
144149
145- my $duk = $self -> {duk } = JavaScript::Duktape::Vm-> perl_duk_new( $max_memory );
150+ my $duk = $self -> {duk } = JavaScript::Duktape::Vm-> perl_duk_new( $max_memory , $timeout );
146151
147152 $self -> {pid } = $$ ;
148153 $self -> {max_memory } = $max_memory ;
Original file line number Diff line number Diff line change @@ -183,14 +183,14 @@ void fatal_handler (void *udata, const char *msg) {
183183/**
184184 * new
185185******************************************************************************/
186- SV * perl_duk_new (const char * classname , size_t max_memory ) {
186+ SV * perl_duk_new (const char * classname , size_t max_memory , int timeout ) {
187187 duk_context * ctx ;
188188 SV * obj ;
189189 SV * obj_ref ;
190190
191191 perlDuk * duk = malloc (sizeof (* duk ));
192192 duk -> ctx = NULL ;
193- duk -> timeout = 0 ;
193+ duk -> timeout = timeout ;
194194 duk -> max_memory = max_memory ;
195195 duk -> total_allocated = 0 ;
196196
You can’t perform that action at this time.
0 commit comments