ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-DBI/DBI.pm
(Generate patch)

Comparing AnyEvent-DBI/DBI.pm (file contents):
Revision 1.2 by root, Fri Jun 6 15:44:34 2008 UTC vs.
Revision 1.3 by root, Fri Jun 6 16:13:07 2008 UTC

13 13
14This module implements asynchronous DBI access my forking or executing 14This module implements asynchronous DBI access my forking or executing
15separate "DBI-Server" processes and sending them requests. 15separate "DBI-Server" processes and sending them requests.
16 16
17It means that you can run DBI requests in parallel to other tasks. 17It means that you can run DBI requests in parallel to other tasks.
18
19The overhead for very simple statements ("select 0") is somewhere
20around 120% to 200% (single/dual core CPU) compared to an explicit
21prepare_cached/execute/fetchrow_arrayref/finish combination.
18 22
19=cut 23=cut
20 24
21package AnyEvent::DBI; 25package AnyEvent::DBI;
22 26
184 } else { 188 } else {
185 $wself->_error ("read error: $!", @caller, 1); 189 $wself->_error ("read error: $!", @caller, 1);
186 } 190 }
187 }); 191 });
188 192
193 $self->{ww_cb} = sub {
194 my $len = syswrite $client, $wself->{wbuf}
195 or return delete $wself->{ww};
196
197 substr $wself->{wbuf}, 0, $len, "";
198 };
199
189 my $pid = fork; 200 my $pid = fork;
190 201
191 if ($pid) { 202 if ($pid) {
192 # parent 203 # parent
193 close $server; 204 close $server;
231 242
232 unless ($self->{ww}) { 243 unless ($self->{ww}) {
233 my $len = syswrite $self->{fh}, $self->{wbuf}; 244 my $len = syswrite $self->{fh}, $self->{wbuf};
234 substr $self->{wbuf}, 0, $len, ""; 245 substr $self->{wbuf}, 0, $len, "";
235 246
236 #TODO, ww_cb
237 # still any left? then install a write watcher 247 # still any left? then install a write watcher
238 $self->{ww} = AnyEvent->io (fh => $self->{fh}, poll => "w", cb => $self->{ww_cb}) 248 $self->{ww} = AnyEvent->io (fh => $self->{fh}, poll => "w", cb => $self->{ww_cb})
239 if length $self->{wbuf}; 249 if length $self->{wbuf};
240 } 250 }
241} 251}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines