Skip to content

Commit 4ed5f89

Browse files
committed
Updated README
1 parent 627df09 commit 4ed5f89

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Javascript-like C++ promise library
1+
# Javascript-like C++ promise library
22

33
This library provides a `Promise` class that aims to mimic the behavior of the typical
44
JavaScript promise object. It does not implement any particular Javascript standard promise
@@ -10,11 +10,15 @@ but schedules the calls on the next message loop iteration. The same happens whe
1010
is attached to an already resolved/rejected promise. This may be a bit less efficient, but makes the behavior symmetric and more predictable. This library resolves synchronously, because it is unaware of the
1111
message loop that is used in the application.
1212

13+
## Compatibility
14+
This library should be compatible with gcc >= 4.9, clang >= 3.3 and Visual Studio >= 2015
15+
16+
# API
1317
A brief overview of the API follows. For practical usage examples and details on the behavior,
1418
please see the included tests in `tests/promise-test.cpp`
1519

1620
## The Promise<T, L> class
17-
Intuitively, the T class is the type of the value, held by the promise object. It can be `void` as well.
21+
Intuitively, the `T` class is the type of the value, held by the promise object. It can be `void` as well.
1822

1923
As for what `L` is - some explanation is needed. When `.then()` and `.fail()` handlers
2024
are attached to a promise, they are added to internal lists. For performance reasons,
@@ -34,10 +38,10 @@ attached when chaining promises. This, however, may not be the case, if the hand
3438
a promise chain, and returns a promise that is not at its end. This is a very exotic case, and is still
3539
perfectly fine with a reasonable number of handlers attached to each of the two promises. In any case,
3640
checks are performed in both debug and release mode and an exception is thrown if callback slots are
37-
exhausted. The exception is of type `std::runtime_error` and an informative message. Please let me know
41+
exhausted. The exception is of type `std::runtime_error` and has an informative message. Please let me know
3842
if the fixed maximum of handlers is a problem for you. If it turns our to be cumbersome for many users,
3943
I will consider switching to dynamic lists.
40-
You can increase the default globally by defining PROMISE_MAX_HANDLE_COUNT before including `promise.hpp`. However, this define-before-include order has to be taken care of for each compilation unit.
44+
You can increase the default globally by defining `PROMISE_MAX_HANDLE_COUNT` before including `promise.hpp`. However, this define-before-include order has to be taken care of for each compilation unit.
4145
This may be cumbersome, if done at the source code level. A better option could be to add the define to the
4246
build system of your application, so that all compilation units will have it specified, and it will always be defined before any code is preprocessed/compiled.
4347
You can also define it per object by overriding the template parameter. This can be done in specific
@@ -94,7 +98,8 @@ Convenience methods to check the state of the promise.
9498
Returns the Error object with which the promise was rejected. If the promise is not in `kRejected` state, an assertion is triggered. Therefore, this method should only be called after a check if the promise is actually
9599
in rejected state.
96100

97-
### `static Promise::when(...), static Promise::when(std::vector<Promise<P>>)`
101+
### `static Promise<void> Promise::when(...)`
102+
### `static Promise<void> Promise::when(std::vector<Promise<P>>)`
98103
Returns a Promise<void> that is:
99104
- Resolved when all the provided promises are resolved.
100105
- Rejected if at least one of the provided promises is rejected.

promise.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
@author Alexander Vassilev
3+
@copyright MEGA Limited, 2014
34
@license BSD 2-Clause "Simplified" License
45
*/
56

tests/promise-test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
@author Alexander Vassilev
3-
@license BSD 2-Clause "Simplified" License
3+
@copyright MEGA Limited, 2014
4+
@license BSD 2-Clause "Simplified" License
45
*/
56

67
//#define TESTLOOP_LOG_DONES

0 commit comments

Comments
 (0)