Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(930)

Unified Diff: samples/myapi/myapi_client.cc

Issue 1209033003: Work in progres, please take a look and give early feedback if this is the way we want to structure… (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: address comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/myapi/myapi.gyp ('k') | samples/myapi/myapi_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/myapi/myapi_client.cc
diff --git a/samples/myapi/myapi_client.cc b/samples/myapi/myapi_client.cc
deleted file mode 100644
index e3e781b3d26233e0089652728bd59f6cab82e8eb..0000000000000000000000000000000000000000
--- a/samples/myapi/myapi_client.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE.md file.
-
-#include "generated/myapi.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-
-static void Setup(char* path);
-static void TearDown();
-
-int main(int argc, char** argv) {
- Setup(argv[1]);
-
- MyApi api = MyApi::create();
- MyObject m0 = api.foo();
- MyObject m1 = api.foo();
- m0.funk(m1);
- m1.funk(m0);
- api.destroy();
-
- TearDown();
-}
-
-
-// -----------------------------------------------------------------------
-
-#include <pthread.h>
-
-#include "include/fletch_api.h"
-#include "include/service_api.h"
-
-static const int kDone = 1;
-
-static pthread_mutex_t mutex;
-static pthread_cond_t cond;
-static int status = 0;
-
-static void ChangeStatusAndNotify(int new_status) {
- pthread_mutex_lock(&mutex);
- status = new_status;
- pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
-}
-
-static void WaitForStatus(int expected) {
- pthread_mutex_lock(&mutex);
- while (expected != status) pthread_cond_wait(&cond, &mutex);
- pthread_mutex_unlock(&mutex);
-}
-
-static void* FletchThreadEntry(void* arg) {
- const char* path = static_cast<char*>(arg);
- FletchSetup();
- FletchRunSnapshotFromFile(path);
- FletchTearDown();
- ChangeStatusAndNotify(kDone);
- return NULL;
-}
-
-static void RunSnapshotInNewThread(char* path) {
- pthread_t thread;
- int result = pthread_create(&thread, NULL, FletchThreadEntry, path);
- if (result != 0) {
- perror("Failed to start thread");
- exit(1);
- }
-}
-
-void Setup(char* path) {
- pthread_mutex_init(&mutex, NULL);
- pthread_cond_init(&cond, NULL);
- ServiceApiSetup();
- RunSnapshotInNewThread(path);
-}
-
-void TearDown() {
- WaitForStatus(kDone);
- ServiceApiTearDown();
-}
-
« no previous file with comments | « samples/myapi/myapi.gyp ('k') | samples/myapi/myapi_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698