Example #1
0
 public function getWeatherAppropriate(GetParam $city, GetParam $state, GetParam $status = null)
 {
     $status = is_null($status) ? null : $status->get();
     $weather = $this->weather->getWeather($city->get(), $state->get());
     error_log(print_r($weather->marshal(), true));
     $outdoorWeather = $weather->getDescription() == "Clear";
     $todos = $this->db->findAll($status, $outdoorWeather);
     return Todo::marshalCollection($todos);
 }
Example #2
0
 public function syncEx(GetParam $fail)
 {
     $shouldFail = $fail->get() == 'true';
     $jobs = [];
     for ($i = 0; $i < 5; $i++) {
         $jobs[] = $this->coll()->simWork($shouldFail);
     }
     try {
         $this->coll()->mkWaitGroup($jobs)->wait();
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
Example #3
0
 public function prime(GetParam $limit)
 {
     $ch = $this->coll()->mkChan();
     $ex = $this->coll()->mkChan();
     for ($i = 2; $i < $limit->get(); $i++) {
         $this->collectIfPrime($ch, $ex, $i);
     }
     $primes = [];
     $r = $this->coll()->mkChanReader([$ch, $ex]);
     $exits = 0;
     while ($exits + 2 < $limit->get()) {
         list($id, $val) = $r->get();
         switch ($id) {
             case $ch->getId():
                 $primes[] = $val;
                 break;
             case $ex->getId():
                 $exits++;
                 break;
         }
     }
     return $primes;
 }
Example #4
0
 public function getFoo(RequestReader $req, PathParam $id, GetParam $type = null)
 {
     return array('method' => $req->getHttpMethod(), 'id' => $id->get(), 'type' => $type == null ? null : $type->get());
 }