Skip to content

Commit

Permalink
Move SerialExecutor to Support (#1404) (#1404)
Browse files Browse the repository at this point in the history
Summary:
Original Author: [email protected]
Original Git: d208805
Original Reviewed By: neildhar
Original Revision: D57689126

Pull Request resolved: #1404

- Move SerialExecutor
- convert `throw`s to `assert`s so it can be built without exceptions
- only adjust the stack for ASAN if in an ASAN build

Reviewed By: neildhar

Differential Revision: D58621440

fbshipit-source-id: 8781a88aab126ad13177a29316e31e917d11484b
  • Loading branch information
dannysu authored and facebook-github-bot committed Jun 16, 2024
1 parent db51a2f commit abaf578
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 21 deletions.
File renamed without changes.
7 changes: 0 additions & 7 deletions lib/SerialExecutor/CMakeLists.txt

This file was deleted.

1 change: 1 addition & 0 deletions lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ add_hermes_library(hermesSupport
PageAccessTrackerPosix.cpp
PerfSection.cpp
SemaphorePosix.cpp
SerialExecutor.cpp
SHA1.cpp
SNPrintfBuf.cpp
SourceErrorManager.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

#include "hermes/SerialExecutor/SerialExecutor.h"
#include <cassert>

#include "hermes/Support/SerialExecutor.h"

namespace hermes {

Expand All @@ -14,22 +16,18 @@ SerialExecutor::SerialExecutor(size_t stackSize) {
pthread_attr_t attr;

int ret;
(void)ret;
ret = pthread_attr_init(&attr);
if (ret != 0) {
throw std::runtime_error("Failed pthread_attr_init");
}
assert(ret == 0 && "Failed pthread_attr_init");

if (stackSize != 0) {
ret = pthread_attr_setstacksize(&attr, stackSize);
if (ret != 0) {
throw std::runtime_error("Failed pthread_attr_setstacksize");
}
assert(ret == 0 && "Failed pthread_attr_setstacksize");
}

ret = pthread_create(&tid_, &attr, SerialExecutor::threadMain, this);
if (ret != 0) {
throw std::runtime_error("Failed pthread_create");
}
assert(ret == 0 && "Failed pthread_create");

#else
workerThread_ = std::thread([this]() { this->run(); });
#endif
Expand Down
2 changes: 1 addition & 1 deletion tools/hcdp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ add_hermes_tool(hcdp
${ALL_HEADER_FILES}
)

target_link_libraries(hcdp hermesSerialExecutor libhermes hermesParser)
target_link_libraries(hcdp hermesSupport libhermes hermesParser)

install(TARGETS hcdp
RUNTIME DESTINATION bin
Expand Down
2 changes: 1 addition & 1 deletion tools/hcdp/hcdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ int main(void) {
#include <sstream>

#include <hermes/Parser/JSONParser.h>
#include <hermes/SerialExecutor/SerialExecutor.h>
#include <hermes/Support/JSONEmitter.h>
#include <hermes/Support/SerialExecutor.h>
#include <hermes/cdp/CDPAgent.h>
#include <hermes/cdp/CDPDebugAPI.h>
#include <hermes/cdp/MessageTypes.h>
Expand Down
2 changes: 1 addition & 1 deletion unittests/API/AsyncDebuggerAPITest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <gtest/gtest.h>

#include <hermes/AsyncDebuggerAPI.h>
#include <hermes/SerialExecutor/SerialExecutor.h>
#include <hermes/Support/SerialExecutor.h>
#include <hermes/hermes.h>
#include <jsi/jsi.h>

Expand Down
2 changes: 1 addition & 1 deletion unittests/API/CDPAgentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

#include <hermes/AsyncDebuggerAPI.h>
#include <hermes/CompileJS.h>
#include <hermes/SerialExecutor/SerialExecutor.h>
#include <hermes/Support/JSONEmitter.h>
#include <hermes/Support/SerialExecutor.h>
#include <hermes/cdp/CDPAgent.h>
#include <hermes/cdp/CDPDebugAPI.h>
#include <hermes/cdp/JSONValueInterfaces.h>
Expand Down

0 comments on commit abaf578

Please sign in to comment.