Merge commit 'upstream/6.040'
Alessandro Ghedini
12 years ago
2 | 2 | TODO: should explore PerlIO::coroaio (perl leaks like hell). |
3 | 3 | TODO: channel->maxsize(newsize)? |
4 | 4 | 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. | |
5 | 16 | |
6 | 17 | 6.02 Wed Jul 13 04:35:19 CEST 2011 |
7 | 18 | - "improve portability to Gentoo" - gentoo manages to put perl variables |
68 | 68 | |
69 | 69 | use base Exporter::; |
70 | 70 | |
71 | our $VERSION = 6.02; | |
71 | our $VERSION = 6.04; | |
72 | 72 | |
73 | 73 | our @EXPORT = (@IO::AIO::EXPORT, qw(aio_wait)); |
74 | 74 | our @EXPORT_OK = @IO::AIO::EXPORT_OK; |
163 | 163 | use Coro; |
164 | 164 | use AnyEvent (); |
165 | 165 | |
166 | our $VERSION = 6.02; | |
166 | our $VERSION = 6.04; | |
167 | 167 | |
168 | 168 | ############################################################################# |
169 | 169 | # idle handler |
182 | 182 | Coro::_set_readyhook (\&AnyEvent::detect); |
183 | 183 | |
184 | 184 | AnyEvent::post_detect { |
185 | unshift @AnyEvent::CondVar::ISA, "Coro::AnyEvent::CondVar"; | |
186 | ||
187 | 185 | my $model = $AnyEvent::MODEL; |
188 | 186 | |
189 | 187 | if ($model eq "AnyEvent::Impl::EV" and eval { require Coro::EV }) { |
220 | 218 | Coro::_set_readyhook \&_activity; |
221 | 219 | |
222 | 220 | $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 | |
224 | 223 | |
225 | 224 | while () { |
226 | $one_event->(); | |
225 | $_poll->(); | |
227 | 226 | Coro::schedule if Coro::nready; |
228 | 227 | } |
229 | 228 | }; |
234 | 233 | # call the readyhook, in case coroutines were already readied |
235 | 234 | _activity; |
236 | 235 | } |
236 | ||
237 | # augment condvars | |
238 | unshift @AnyEvent::CondVar::ISA, "Coro::AnyEvent::CondVar"; | |
237 | 239 | }; |
238 | 240 | |
239 | 241 | =item Coro::AnyEvent::poll |
344 | 346 | Coro::rouse_wait |
345 | 347 | } |
346 | 348 | |
347 | ############################################################################# | |
348 | # override condvars | |
349 | ||
350 | package Coro::AnyEvent::CondVar; | |
351 | ||
352 | sub _send { | |
349 | sub Coro::AnyEvent::CondVar::send { | |
353 | 350 | (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}) { | |
358 | 357 | local $_[0]{_ae_coro} = $Coro::current; |
359 | 358 | Coro::schedule; |
360 | 359 | } |
361 | } | |
360 | ||
361 | AnyEvent::CondVar::Base::recv $_[0]; | |
362 | }; | |
362 | 363 | |
363 | 364 | 1; |
364 | 365 |
46 | 46 | |
47 | 47 | use base Exporter::; |
48 | 48 | |
49 | our $VERSION = 6.02; | |
49 | our $VERSION = 6.04; | |
50 | 50 | our $WATCHER; |
51 | 51 | |
52 | 52 | BDB::set_sync_prepare { |
34 | 34 | use Coro (); |
35 | 35 | use Coro::Semaphore (); |
36 | 36 | |
37 | our $VERSION = 6.02; | |
37 | our $VERSION = 6.04; | |
38 | 38 | |
39 | 39 | sub DATA (){ 0 } |
40 | 40 | sub SGET (){ 1 } |
120 | 120 | use Coro::AnyEvent (); |
121 | 121 | use Coro::Timer (); |
122 | 122 | |
123 | our $VERSION = 6.02; | |
123 | our $VERSION = 6.04; | |
124 | 124 | |
125 | 125 | our %log; |
126 | 126 | our $SESLOGLEVEL = exists $ENV{PERL_CORO_DEFAULT_LOGLEVEL} ? $ENV{PERL_CORO_DEFAULT_LOGLEVEL} : -1; |
44 | 44 | |
45 | 45 | use base 'Exporter'; |
46 | 46 | |
47 | our $VERSION = 6.02; | |
47 | our $VERSION = 6.04; | |
48 | 48 | our @EXPORT = qw(unblock); |
49 | 49 | |
50 | 50 | =item $fh = new_from_fh Coro::Handle $fhandle [, arg => value...] |
125 | 125 | use Net::FTP (); |
126 | 126 | use Net::NNTP (); |
127 | 127 | |
128 | our $VERSION = 6.02; | |
128 | our $VERSION = 6.04; | |
129 | 129 | |
130 | 130 | *Socket::inet_aton = \&Coro::Util::inet_aton; |
131 | 131 |
6 | 6 | |
7 | 7 | our $installsitearch; |
8 | 8 | |
9 | our $VERSION = 6.02; | |
9 | our $VERSION = 6.04; | |
10 | 10 | our @EXPORT_OK = qw(&coro_args $installsitearch); |
11 | 11 | |
12 | 12 | my %opt; |
37 | 37 | |
38 | 38 | use Coro (); |
39 | 39 | |
40 | our $VERSION = 6.02; | |
40 | our $VERSION = 6.04; | |
41 | 41 | |
42 | 42 | =item $l = new Coro::RWLock; |
43 | 43 |
66 | 66 | |
67 | 67 | use base Exporter::; |
68 | 68 | |
69 | our $VERSION = 6.02; | |
69 | our $VERSION = 6.04; | |
70 | 70 | our @EXPORT_OK = "select"; |
71 | 71 | |
72 | 72 | sub import { |
39 | 39 | |
40 | 40 | use Coro (); |
41 | 41 | |
42 | our $VERSION = 6.02; | |
42 | our $VERSION = 6.04; | |
43 | 43 | |
44 | 44 | =item new [inital count] |
45 | 45 |
34 | 34 | |
35 | 35 | use common::sense; |
36 | 36 | |
37 | our $VERSION = 6.02; | |
37 | our $VERSION = 6.04; | |
38 | 38 | |
39 | 39 | use Coro::Semaphore (); |
40 | 40 |
37 | 37 | |
38 | 38 | use Coro::Semaphore (); |
39 | 39 | |
40 | our $VERSION = 6.02; | |
40 | our $VERSION = 6.04; | |
41 | 41 | |
42 | 42 | =item $sig = new Coro::Signal; |
43 | 43 |
72 | 72 | |
73 | 73 | use base qw(Coro::Handle IO::Socket::INET); |
74 | 74 | |
75 | our $VERSION = 6.02; | |
75 | our $VERSION = 6.04; | |
76 | 76 | |
77 | 77 | our (%_proto, %_port); |
78 | 78 |
35 | 35 | |
36 | 36 | use common::sense; |
37 | 37 | |
38 | our $VERSION = 6.02; | |
38 | our $VERSION = 6.04; | |
39 | 39 | |
40 | 40 | =item new |
41 | 41 |
89 | 89 | use XSLoader; |
90 | 90 | |
91 | 91 | BEGIN { |
92 | our $VERSION = 6.02; | |
92 | our $VERSION = 6.04; | |
93 | 93 | |
94 | 94 | # must be done here because the xs part expects it to exist |
95 | 95 | # it might exist already because Coro::Specific created it. |
83 | 83 | use Storable; |
84 | 84 | use base "Exporter"; |
85 | 85 | |
86 | our $VERSION = 6.02; | |
86 | our $VERSION = 6.04; | |
87 | 87 | our @EXPORT = qw(thaw freeze nfreeze blocking_thaw blocking_freeze blocking_nfreeze); |
88 | 88 | |
89 | 89 | our $GRANULARITY = 0.01; |
29 | 29 | use Coro (); |
30 | 30 | use Coro::AnyEvent (); |
31 | 31 | |
32 | our $VERSION = 6.02; | |
32 | our $VERSION = 6.04; | |
33 | 33 | our @EXPORT_OK = qw(timeout sleep); |
34 | 34 | |
35 | 35 | # compatibility with older programs |
40 | 40 | our @EXPORT = qw(gethostbyname gethostbyaddr); |
41 | 41 | our @EXPORT_OK = qw(inet_aton fork_eval); |
42 | 42 | |
43 | our $VERSION = 6.02; | |
43 | our $VERSION = 6.04; | |
44 | 44 | |
45 | 45 | our $MAXPARALLEL = 16; # max. number of parallel jobs |
46 | 46 |
62 | 62 | #endif |
63 | 63 | #endif |
64 | 64 | |
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 | ||
65 | 117 | #define ECB_C99 (__STDC_VERSION__ >= 199901L) |
66 | 118 | |
67 | 119 | #if __cplusplus |
343 | 343 | our $main; # main coro |
344 | 344 | our $current; # current coro |
345 | 345 | |
346 | our $VERSION = 6.02; | |
346 | our $VERSION = 6.04; | |
347 | 347 | |
348 | 348 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub rouse_cb rouse_wait); |
349 | 349 | our %EXPORT_TAGS = ( |
59 | 59 | use XSLoader; |
60 | 60 | |
61 | 61 | BEGIN { |
62 | our $VERSION = 6.02; | |
62 | our $VERSION = 6.04; | |
63 | 63 | |
64 | 64 | local $^W = 0; # avoid redefine warning for Coro::ready; |
65 | 65 | XSLoader::load __PACKAGE__, $VERSION; |
242 | 242 | dir = wr ? &data->w : &data->r; |
243 | 243 | |
244 | 244 | 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"); | |
246 | 246 | |
247 | 247 | dir->data = sv_2mortal (newRV_inc (CORO_CURRENT)); |
248 | 248 |
91 | 91 | our @EXPORT = qw(loop unloop sweep); |
92 | 92 | |
93 | 93 | BEGIN { |
94 | our $VERSION = 6.02; | |
94 | our $VERSION = 6.04; | |
95 | 95 | |
96 | 96 | local $^W = 0; # avoid redefine warning for Coro::ready; |
97 | 97 | XSLoader::load __PACKAGE__, $VERSION; |
92 | 92 | |
93 | 93 | doc/cede-vs-schedule |
94 | 94 | |
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) |
0 | 0 | { |
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", | |
1 | 15 | "no_index" : { |
2 | 16 | "directory" : [ |
3 | 17 | "t", |
4 | 18 | "inc" |
5 | 19 | ] |
6 | 20 | }, |
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 | } | |
10 | 50 | }, |
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" | |
40 | 53 | } |
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 |