1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 04:24:42 +01:00
Commit Graph

98 Commits

Author SHA1 Message Date
Daniel Lowrey
2e1ef0b739 Implement Closure::call() 2015-03-16 15:03:52 -04:00
Daniel Lowrey
834255163c Refactor coroutine functionality 2015-03-16 15:00:17 -04:00
Daniel Lowrey
a573e195a6 Allow null implicit yields 2015-02-18 09:53:55 -05:00
Daniel Lowrey
24acba4486 Merge branch 'psr' of https://github.com/lyrixx/amp into lyrixx-psr 2015-02-05 23:54:12 -05:00
Grégoire Pineau
01d50d10f9 Fixex typos 2015-02-05 18:17:05 +01:00
Daniel Lowrey
99e38762a7 - Added Reactor::coroutine() method
- Added `Amp\coroutine()` function
- `YieldCommands` "enum" constant class removed -- yield keys now live in
  the reactor class
- New optional `"coroutine"` yield key for self-documenting generator
  yields.
- New optional `"async"` yield key for self-documenting promise yields.
- New `"return"` yield key for specifying the return value of a resolved
  Generator coroutine. If not specified a resolved coroutine result is
  equal to null.
- The final value yielded by a resolved `Generator` is *no longer* used
  as its "return" value. Instead, generators must manually use the new
  `"return"` yield key specifically to designate the value that should
  be used to resolve the promise associated with generator resolution.
- `GeneratorResolver` trait renamed to `CoroutineResolver` and is now an
  abstract class extended by the various `Reactor` implementations.
- Implicit "all" array combinator resolution is now removed. Use the
  explicit form instead:

```php
function() {
    list($a, $b, $c) = (yield 'all' => [$promise1, $promise2, $promise3]);
};
```
2015-02-03 19:41:15 -05:00
Daniel Lowrey
7e451251ab Make Amp\Struct abstract to better represent its purpose 2015-01-28 22:30:02 -05:00
Daniel Lowrey
ab89cb1595 Remove unused variable 2015-01-21 20:19:47 -05:00
Daniel Lowrey
fb60221dcd Correctly re-enable stream polls in UvReactor 2015-01-21 20:16:33 -05:00
Markus Staab
474c636845 Removed unused var 2015-01-21 23:00:41 +01:00
Bob Weinand
2ff42636aa Fix waiting for immediates resolution
If there are immediates generated in immediates, they have to wait until next tick - which may only be triggered in far future or never, depending on if there are other read/writeWatchers or timers So, now just do a single event run without blocking if there are new immediates generated during immediates execution
2015-01-21 21:39:12 +01:00
Daniel Lowrey
9edef1d5a7 Fix UvReactor notices 2015-01-18 20:13:08 -05:00
Douglas G.R
cf3e13a595 Throws a RuntimeException if php-uv or libevent is not loaded.
Using UvReactor or LibeventReactor directly (instead of Amp\getReactor)
doesn't check if php-uv/libevent is loaded and dies with a 'Call to undefined
function' message.
2015-01-06 00:01:07 -02:00
Daniel Lowrey
a99b923819 Remove superfluous if conditional 2014-12-08 11:56:26 -05:00
Daniel Lowrey
0360aec301 Fix NativeReactor::tick() weirdness 2014-12-08 09:50:16 -05:00
Daniel Lowrey
bbfca9f7ac Avoid unnecessary uv_timer_stop() when cleaning up once timers 2014-12-05 00:09:47 -05:00
Daniel Lowrey
49b7a73a8d Minor libevent reactor bugfixes 2014-12-04 19:30:23 -05:00
Daniel Lowrey
b11e7a0fd1 Fix combinator function derps (again) 2014-12-04 18:08:13 -05:00
Daniel Lowrey
b93238eb1b Fix bad instantiation class name 2014-12-04 17:59:27 -05:00
Daniel Lowrey
a8fe6e2e39 Fix combinator function derps 2014-12-04 13:34:42 -05:00
Daniel Lowrey
d795923318 Handle "@" yield key as implicit "nowait" 2014-12-02 14:47:51 -05:00
Daniel Lowrey
934d1aeffb Return promise/result from bound functions 2014-12-02 12:43:00 -05:00
Daniel Lowrey
62de0cbc18 Implement 'bind' yield command 2014-12-02 11:52:41 -05:00
Daniel Lowrey
090bdf55ed Rename "wait" yield command -> "pause" to avoid confusion with "nowait" and Amp\wait() 2014-12-02 11:29:19 -05:00
Daniel Lowrey
ba55ae360f Fix minor inconsistency Reactor::stop() called from immediately watcher 2014-12-02 01:09:51 -05:00
Daniel Lowrey
dd1cbf8ca1 Merge branch 'debugInfo'
Conflicts:
	lib/LibeventReactor.php
	lib/NativeReactor.php
	lib/UvReactor.php
2014-12-02 01:06:36 -05:00
Daniel Lowrey
14c209012c Add Reactor::__debugInfo() for easier debugging 2014-12-02 00:45:12 -05:00
Daniel Lowrey
f32d088c23 Lots of changes ... see CHANGELOG for details 2014-12-01 19:45:57 -05:00
Daniel Lowrey
0d7ab5fc6c Add Reactor::onError, correctly exit extension reactor loops, replace resolve function with trait 2014-12-01 18:12:26 -05:00
Daniel Lowrey
1480eecaba Remove newloop protection from UvReactor 2014-12-01 15:39:57 -05:00
Daniel Lowrey
f686691892 Add Reactor::tick() 2014-11-26 15:53:18 -05:00
Daniel Lowrey
6d5e15d662 Apply boolean DeMorgan simplification 2014-11-26 15:49:14 -05:00
Chris Wright
c6b5d4fd17 Don't stop when there are immediates left 2014-11-26 17:03:18 +00:00
Daniel Lowrey
c75a8514a1 Reactor is now optional for combinator functions 2014-11-25 12:46:29 -05:00
Daniel Lowrey
0e9c4a1818 Require Reactor when instantiating Promisor implementations 2014-11-24 23:17:43 -05:00
Daniel Lowrey
1cb293b776 Remove Combinator/Resolver in favor of functions
This commit removes the Combinator and Resolver classes altogether.
The relevant functionality is now concentrated entirely in the
analogous functions:

- all()
- some()
- any()
- first()
- map()
- filter()
- resolve()

Additionally, all Promisor implementations now *require* a Reactor
upon instantiation. Previously this parameter could be null and the
static singleton reactor instance would be used automatically.
2014-11-24 23:14:07 -05:00
Daniel Lowrey
398c1a6790 Don't hammer the CPU with NOWAIT ticks 2014-11-18 10:08:34 -05:00
Daniel Lowrey
2d5a1eb643 Allow multiple IO watchers on a stream without borking libuv 2014-11-18 10:08:34 -05:00
Daniel Lowrey
ccc0bdcbe0 Remove unused Reactor constants 2014-11-18 10:08:34 -05:00
Daniel Lowrey
d5c494afb1 Implement safer struct usage 2014-11-18 10:08:34 -05:00
Daniel Lowrey
2a84f46853 Fix breakage if ext/openssl missing in windows 2014-11-18 10:08:34 -05:00
Daniel Lowrey
874e7dab90 Formalize resolver yield commands 2014-11-05 11:56:35 -05:00
Daniel Lowrey
c28e143828 Remove watchStream() ... aliases are bad 2014-11-05 11:50:46 -05:00
Daniel Lowrey
70222364d5 Use singleton reactor instance in functions 2014-11-04 09:46:12 -05:00
Daniel Lowrey
2fd6538e47 Fix infinite loop on nested immediately watchers in LibeventReactor 2014-10-22 22:18:34 -04:00
Daniel Lowrey
7b11a8e0c3 Rename any() -> some(), change any() to never fail 2014-10-22 18:14:43 -04:00
Daniel Lowrey
f1f967e0ce Fix file permissions 2014-10-22 18:14:15 -04:00
Daniel Lowrey
634d978aeb Simplify reactor onStart() callback invocation 2014-10-22 18:14:01 -04:00
Daniel Lowrey
21e7ddbff9 Add key shortcuts, fix tick starvation when resolving looped yields 2014-10-22 18:12:36 -04:00
Daniel Lowrey
d719e302a6 Fix syntax error 2014-10-20 12:08:09 -04:00