You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-5Lines changed: 10 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
##Javascript-like C++ promise library
1
+
# Javascript-like C++ promise library
2
2
3
3
This library provides a `Promise` class that aims to mimic the behavior of the typical
4
4
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
10
10
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
11
11
message loop that is used in the application.
12
12
13
+
## Compatibility
14
+
This library should be compatible with gcc >= 4.9, clang >= 3.3 and Visual Studio >= 2015
15
+
16
+
# API
13
17
A brief overview of the API follows. For practical usage examples and details on the behavior,
14
18
please see the included tests in `tests/promise-test.cpp`
15
19
16
20
## 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.
18
22
19
23
As for what `L` is - some explanation is needed. When `.then()` and `.fail()` handlers
20
24
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
34
38
a promise chain, and returns a promise that is not at its end. This is a very exotic case, and is still
35
39
perfectly fine with a reasonable number of handlers attached to each of the two promises. In any case,
36
40
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
38
42
if the fixed maximum of handlers is a problem for you. If it turns our to be cumbersome for many users,
39
43
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.
41
45
This may be cumbersome, if done at the source code level. A better option could be to add the define to the
42
46
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.
43
47
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.
94
98
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
0 commit comments