Codebase list libcoro-perl / upstream/6.040
Imported Upstream version 6.040 Alessandro Ghedini 12 years ago
37 changed file(s) with 183 addition(s) and 71 deletion(s). Raw diff Collapse all Expand all
22 TODO: should explore PerlIO::coroaio (perl leaks like hell).
33 TODO: channel->maxsize(newsize)?
44 TODO: http://www.microsoft.com/msj/archive/s2ce.aspx
5
6 6.04 Wed Aug 3 17:15:45 CEST 2011
7 - use even more efficient and more compatible condvars for
8 compatibility to AnyEvent 6.x :)
9 - more inconsequential ecb.h updates.
10
11 6.03 Wed Aug 3 11:41:30 CEST 2011
12 - change how Coro patches AnyEvent condvars for compatibility to
13 AnyEvent 6.x.
14 - update ecb.h, to no longer include <pthread.h> in case WinNT.h
15 hasn't been included.
516
617 6.02 Wed Jul 13 04:35:19 CEST 2011
718 - "improve portability to Gentoo" - gentoo manages to put perl variables
6868
6969 use base Exporter::;
7070
71 our $VERSION = 6.02;
71 our $VERSION = 6.04;
7272
7373 our @EXPORT = (@IO::AIO::EXPORT, qw(aio_wait));
7474 our @EXPORT_OK = @IO::AIO::EXPORT_OK;
163163 use Coro;
164164 use AnyEvent ();
165165
166 our $VERSION = 6.02;
166 our $VERSION = 6.04;
167167
168168 #############################################################################
169169 # idle handler
182182 Coro::_set_readyhook (\&AnyEvent::detect);
183183
184184 AnyEvent::post_detect {
185 unshift @AnyEvent::CondVar::ISA, "Coro::AnyEvent::CondVar";
186
187185 my $model = $AnyEvent::MODEL;
188186
189187 if ($model eq "AnyEvent::Impl::EV" and eval { require Coro::EV }) {
220218 Coro::_set_readyhook \&_activity;
221219
222220 $IDLE = new Coro sub {
223 my $one_event = AnyEvent->can ("one_event");
221 my $_poll = AnyEvent->can ("_poll")
222 || AnyEvent->can ("one_event"); # AnyEvent < 6.0
224223
225224 while () {
226 $one_event->();
225 $_poll->();
227226 Coro::schedule if Coro::nready;
228227 }
229228 };
234233 # call the readyhook, in case coroutines were already readied
235234 _activity;
236235 }
236
237 # augment condvars
238 unshift @AnyEvent::CondVar::ISA, "Coro::AnyEvent::CondVar";
237239 };
238240
239241 =item Coro::AnyEvent::poll
344346 Coro::rouse_wait
345347 }
346348
347 #############################################################################
348 # override condvars
349
350 package Coro::AnyEvent::CondVar;
351
352 sub _send {
349 sub Coro::AnyEvent::CondVar::send {
353350 (delete $_[0]{_ae_coro})->ready if $_[0]{_ae_coro};
354 }
355
356 sub _wait {
357 while (!$_[0]{_ae_sent}) {
351
352 AnyEvent::CondVar::Base::send $_[0];
353 };
354
355 sub Coro::AnyEvent::CondVar::recv {
356 until ($_[0]{_ae_sent}) {
358357 local $_[0]{_ae_coro} = $Coro::current;
359358 Coro::schedule;
360359 }
361 }
360
361 AnyEvent::CondVar::Base::recv $_[0];
362 };
362363
363364 1;
364365
4646
4747 use base Exporter::;
4848
49 our $VERSION = 6.02;
49 our $VERSION = 6.04;
5050 our $WATCHER;
5151
5252 BDB::set_sync_prepare {
3434 use Coro ();
3535 use Coro::Semaphore ();
3636
37 our $VERSION = 6.02;
37 our $VERSION = 6.04;
3838
3939 sub DATA (){ 0 }
4040 sub SGET (){ 1 }
120120 use Coro::AnyEvent ();
121121 use Coro::Timer ();
122122
123 our $VERSION = 6.02;
123 our $VERSION = 6.04;
124124
125125 our %log;
126126 our $SESLOGLEVEL = exists $ENV{PERL_CORO_DEFAULT_LOGLEVEL} ? $ENV{PERL_CORO_DEFAULT_LOGLEVEL} : -1;
4444
4545 use base 'Exporter';
4646
47 our $VERSION = 6.02;
47 our $VERSION = 6.04;
4848 our @EXPORT = qw(unblock);
4949
5050 =item $fh = new_from_fh Coro::Handle $fhandle [, arg => value...]
125125 use Net::FTP ();
126126 use Net::NNTP ();
127127
128 our $VERSION = 6.02;
128 our $VERSION = 6.04;
129129
130130 *Socket::inet_aton = \&Coro::Util::inet_aton;
131131
66
77 our $installsitearch;
88
9 our $VERSION = 6.02;
9 our $VERSION = 6.04;
1010 our @EXPORT_OK = qw(&coro_args $installsitearch);
1111
1212 my %opt;
3737
3838 use Coro ();
3939
40 our $VERSION = 6.02;
40 our $VERSION = 6.04;
4141
4242 =item $l = new Coro::RWLock;
4343
6666
6767 use base Exporter::;
6868
69 our $VERSION = 6.02;
69 our $VERSION = 6.04;
7070 our @EXPORT_OK = "select";
7171
7272 sub import {
3939
4040 use Coro ();
4141
42 our $VERSION = 6.02;
42 our $VERSION = 6.04;
4343
4444 =item new [inital count]
4545
3434
3535 use common::sense;
3636
37 our $VERSION = 6.02;
37 our $VERSION = 6.04;
3838
3939 use Coro::Semaphore ();
4040
3737
3838 use Coro::Semaphore ();
3939
40 our $VERSION = 6.02;
40 our $VERSION = 6.04;
4141
4242 =item $sig = new Coro::Signal;
4343
7272
7373 use base qw(Coro::Handle IO::Socket::INET);
7474
75 our $VERSION = 6.02;
75 our $VERSION = 6.04;
7676
7777 our (%_proto, %_port);
7878
3535
3636 use common::sense;
3737
38 our $VERSION = 6.02;
38 our $VERSION = 6.04;
3939
4040 =item new
4141
8989 use XSLoader;
9090
9191 BEGIN {
92 our $VERSION = 6.02;
92 our $VERSION = 6.04;
9393
9494 # must be done here because the xs part expects it to exist
9595 # it might exist already because Coro::Specific created it.
8383 use Storable;
8484 use base "Exporter";
8585
86 our $VERSION = 6.02;
86 our $VERSION = 6.04;
8787 our @EXPORT = qw(thaw freeze nfreeze blocking_thaw blocking_freeze blocking_nfreeze);
8888
8989 our $GRANULARITY = 0.01;
2929 use Coro ();
3030 use Coro::AnyEvent ();
3131
32 our $VERSION = 6.02;
32 our $VERSION = 6.04;
3333 our @EXPORT_OK = qw(timeout sleep);
3434
3535 # compatibility with older programs
4040 our @EXPORT = qw(gethostbyname gethostbyaddr);
4141 our @EXPORT_OK = qw(inet_aton fork_eval);
4242
43 our $VERSION = 6.02;
43 our $VERSION = 6.04;
4444
4545 our $MAXPARALLEL = 16; # max. number of parallel jobs
4646
6262 #endif
6363 #endif
6464
65 /*****************************************************************************/
66
67 #ifndef ECB_MEMORY_FENCE
68 #if ECB_GCC_VERSION(2,5)
69 #if __x86
70 #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory")
71 #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE /* non-lock xchg might be enough */
72 #define ECB_MEMORY_FENCE_RELEASE do { } while (0) /* unlikely to change in future cpus */
73 #elif __amd64
74 #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory")
75 #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("lfence" : : : "memory")
76 #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("sfence") /* play safe - not needed in any current cpu */
77 #endif
78 #endif
79 #endif
80
81 #ifndef ECB_MEMORY_FENCE
82 #if ECB_GCC_VERSION(4,4)
83 #define ECB_MEMORY_FENCE __sync_synchronize ()
84 #define ECB_MEMORY_FENCE_ACQUIRE ({ char dummy = 0; __sync_lock_test_and_set (&dummy, 1); })
85 #define ECB_MEMORY_FENCE_RELEASE ({ char dummy = 1; __sync_lock_release (&dummy ); })
86 #elif _MSC_VER >= 1400 /* VC++ 2005 */
87 #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier)
88 #define ECB_MEMORY_FENCE _ReadWriteBarrier ()
89 #define ECB_MEMORY_FENCE_ACQUIRE _ReadWriteBarrier () /* according to msdn, _ReadBarrier is not a load fence */
90 #define ECB_MEMORY_FENCE_RELEASE _WriteBarrier ()
91 #elif defined(_WIN32)
92 #include <WinNT.h>
93 #define ECB_MEMORY_FENCE MemoryBarrier () /* actually just xchg on x86... scary */
94 #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
95 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
96 #endif
97 #endif
98
99 #ifndef ECB_MEMORY_FENCE
100 /*
101 * if you get undefined symbol references to pthread_mutex_lock,
102 * or failure to find pthread.h, then you should implement
103 * the ECB_MEMORY_FENCE operations for your cpu/compiler
104 * OR proide pthread.h and link against the posix thread library
105 * of your system.
106 */
107 #include <pthread.h>
108
109 static pthread_mutex_t ecb_mf_lock = PTHREAD_MUTEX_INITIALIZER;
110 #define ECB_MEMORY_FENCE do { pthread_mutex_lock (&ecb_mf_lock); pthread_mutex_unlock (&ecb_mf_lock); } while (0)
111 #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
112 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
113 #endif
114
115 /*****************************************************************************/
116
65117 #define ECB_C99 (__STDC_VERSION__ >= 199901L)
66118
67119 #if __cplusplus
343343 our $main; # main coro
344344 our $current; # current coro
345345
346 our $VERSION = 6.02;
346 our $VERSION = 6.04;
347347
348348 our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub rouse_cb rouse_wait);
349349 our %EXPORT_TAGS = (
5959 use XSLoader;
6060
6161 BEGIN {
62 our $VERSION = 6.02;
62 our $VERSION = 6.04;
6363
6464 local $^W = 0; # avoid redefine warning for Coro::ready;
6565 XSLoader::load __PACKAGE__, $VERSION;
242242 dir = wr ? &data->w : &data->r;
243243
244244 if (ev_is_active (&dir->io) || ev_is_active (&dir->tw))
245 croak ("recursive invocation of readable_ev or writable_ev");
245 croak ("recursive invocation of readable_ev or writable_ev (concurrent Coro::Handle calls on same handle?), detected");
246246
247247 dir->data = sv_2mortal (newRV_inc (CORO_CURRENT));
248248
9191 our @EXPORT = qw(loop unloop sweep);
9292
9393 BEGIN {
94 our $VERSION = 6.02;
94 our $VERSION = 6.04;
9595
9696 local $^W = 0; # avoid redefine warning for Coro::ready;
9797 XSLoader::load __PACKAGE__, $VERSION;
9292
9393 doc/cede-vs-schedule
9494
95 META.json Module meta-data (added by MakeMaker)
95 META.yml Module YAML meta-data (added by MakeMaker)
96 META.json Module JSON meta-data (added by MakeMaker)
00 {
1 "abstract" : "unknown",
2 "author" : [
3 "unknown"
4 ],
5 "dynamic_config" : 1,
6 "generated_by" : "ExtUtils::MakeMaker version 6.58, CPAN::Meta::Converter version 2.110930001",
7 "license" : [
8 "unknown"
9 ],
10 "meta-spec" : {
11 "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
12 "version" : "2"
13 },
14 "name" : "Coro",
115 "no_index" : {
216 "directory" : [
317 "t",
418 "inc"
519 ]
620 },
7 "meta-spec" : {
8 "version" : 1.4,
9 "url" : "http://module-build.sourceforge.net/META-spec-v1.4.html"
21 "prereqs" : {
22 "build" : {
23 "requires" : {
24 "ExtUtils::MakeMaker" : 0
25 }
26 },
27 "configure" : {
28 "requires" : {
29 "ExtUtils::MakeMaker" : 0
30 }
31 },
32 "runtime" : {
33 "recommends" : {
34 "AnyEvent::AIO" : "1",
35 "AnyEvent::BDB" : "1",
36 "BDB" : 0,
37 "EV" : "3",
38 "Event" : "1.08",
39 "IO::AIO" : "3.1"
40 },
41 "requires" : {
42 "AnyEvent" : "5",
43 "Guard" : "0.5",
44 "Scalar::Util" : 0,
45 "Storable" : "2.15",
46 "Time::HiRes" : 0,
47 "common::sense" : 0
48 }
49 }
1050 },
11 "generated_by" : "ExtUtils::MakeMaker::JSONMETA version 7.000",
12 "distribution_type" : "module",
13 "version" : "6.02",
14 "name" : "Coro",
15 "author" : [],
16 "license" : "unknown",
17 "build_requires" : {
18 "ExtUtils::MakeMaker" : 0
19 },
20 "requires" : {
21 "Scalar::Util" : 0,
22 "AnyEvent" : 5,
23 "Guard" : 0.5,
24 "Storable" : 2.15,
25 "Time::HiRes" : 0,
26 "common::sense" : 0
27 },
28 "recommends" : {
29 "BDB" : 0,
30 "AnyEvent::AIO" : 1,
31 "Event" : 1.08,
32 "EV" : 3,
33 "IO::AIO" : 3.1,
34 "AnyEvent::BDB" : 1
35 },
36 "abstract" : null,
37 "configure_requires" : {
38 "ExtUtils::MakeMaker" : 0
39 }
51 "release_status" : "stable",
52 "version" : "6.04"
4053 }
0 ---
1 abstract: unknown
2 author:
3 - unknown
4 build_requires:
5 ExtUtils::MakeMaker: 0
6 configure_requires:
7 ExtUtils::MakeMaker: 0
8 dynamic_config: 1
9 generated_by: 'ExtUtils::MakeMaker version 6.58, CPAN::Meta::Converter version 2.110930001'
10 license: unknown
11 meta-spec:
12 url: http://module-build.sourceforge.net/META-spec-v1.4.html
13 version: 1.4
14 name: Coro
15 no_index:
16 directory:
17 - t
18 - inc
19 recommends:
20 AnyEvent::AIO: 1
21 AnyEvent::BDB: 1
22 BDB: 0
23 EV: 3
24 Event: 1.08
25 IO::AIO: 3.1
26 requires:
27 AnyEvent: 5
28 Guard: 0.5
29 Scalar::Util: 0
30 Storable: 2.15
31 Time::HiRes: 0
32 common::sense: 0
33 version: 6.04
(No changes)
(No changes)
(No changes)
(No changes)
(No changes)
(No changes)
(No changes)
(No changes)
(No changes)