FastArduino  v1.8
C++ library to build fast but small Arduino/AVR projects
future.cpp
1 // Copyright 2016-2021 Jean-Francois Poilpret
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "future.h"
16 
17 namespace future
18 {
20  // Add utility ostream manipulator for FutureStatus
21  static const flash::FlashStorage* convert(future::FutureStatus s)
22  {
23  switch (s)
24  {
25  case future::FutureStatus::NOT_READY:
26  return F("NOT_READY");
27 
29  return F("READY");
30 
31  case future::FutureStatus::ERROR:
32  return F("ERROR");
33 
35  return F("INVALID");
36  }
37  }
38 
40  {
41  return out << convert(s);
42  }
44 }
future::FutureStatus::NOT_READY
@ NOT_READY
The status of a Future immediately after it has been constructed.
future
Contains the API around Future implementation.
Definition: future.cpp:18
future.h
Utility API to handle the concept of futures.
streams::ostream
Output stream wrapper to provide formatted output API, a la C++.
Definition: streams.h:61
future::FutureStatus::READY
@ READY
The status of a Future once its output value has been fully set by a provider.
future::FutureStatus
FutureStatus
Status of a Future.
Definition: future.h:119
F
#define F(ptr)
Force string constant to be stored as flash storage.
Definition: flash.h:118