forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for RuntimeScheduler::scheduletTask and RuntimeScheduler::g…
…etShouldYield Summary: Changelog: [internal] Add tests for `RuntimeScheduler::scheduleTask` and `RuntimeScheduler::getShouldYield` Reviewed By: JoshuaGross Differential Revision: D27764464 fbshipit-source-id: 8f95dfd9ec1ddf9a0ee17d489961b19e4ceaa9de
- Loading branch information
1 parent
e3a4de8
commit 4c1fd97
Showing
4 changed files
with
177 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
ReactCommon/react/renderer/runtimescheduler/tests/StubQueue.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <queue> | ||
|
||
class StubQueue { | ||
public: | ||
void runOnQueue(std::function<void()> &&func) { | ||
callbackQueue_.push(func); | ||
} | ||
|
||
void tick() { | ||
if (!callbackQueue_.empty()) { | ||
auto callback = callbackQueue_.front(); | ||
callback(); | ||
callbackQueue_.pop(); | ||
} | ||
} | ||
|
||
int size() { | ||
return callbackQueue_.size(); | ||
} | ||
|
||
private: | ||
std::queue<std::function<void()>> callbackQueue_; | ||
}; |