source: launchers/macosx/obj-cpp/RouterTask.h @ 6d0f80f

Last change on this file since 6d0f80f was 6d0f80f, checked in by meeh <meeh@…>, 2 years ago

Fixed a load of issues related to my "sync" approach, and Mac OSX's "async" API.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#pragma once
2
3#include <dispatch/dispatch.h>
4#include <functional>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include <Cocoa/Cocoa.h>
10#import <AppKit/AppKit.h>
11
12#include "optional.hpp"
13#include "subprocess.hpp"
14
15
16@class RTaskOptions;
17
18@interface RTaskOptions : NSObject
19@property (strong) NSString* binPath;
20@property (strong) NSArray<NSString *>* arguments;
21@property (strong) NSString* i2pBaseDir;
22@end
23
24@class RouterTask;
25
26@interface RouterTask : NSObject
27@property (strong) NSTask* routerTask;
28@property (strong) NSUserDefaults *userPreferences;
29@property (strong) NSFileHandle *readLogHandle;
30@property (strong) NSMutableData *totalLogData;
31@property (strong) NSPipe *processPipe;
32@property (strong) NSFileHandle *input;
33- (instancetype) initWithOptions : (RTaskOptions*) options;
34- (int) execute;
35- (int) getPID;
36@end
37
38
39
40using namespace subprocess;
41
42class JavaRunner;
43
44typedef std::function<void(void)> fp_t;
45typedef std::function<void(JavaRunner *ptr)> fp_proc_t;
46
47/**
48 *
49 * class JavaRunner
50 *
51 **/
52class JavaRunner
53{
54public:
55  // copy fn
56  JavaRunner(std::string& javaBin, std::string& arguments, std::string& i2pBaseDir, const fp_proc_t& executingFn, const fp_t& cb);
57  ~JavaRunner() = default;
58
59  static const std::vector<NSString*> defaultStartupFlags;
60  static const std::vector<std::string> defaultFlagsForExtractorJob;
61
62  void requestRouterShutdown();
63
64  std::experimental::optional<std::future<int> > execute();
65  std::shared_ptr<Popen> javaProcess;
66  std::string javaBinaryPath;
67  std::string javaRouterArgs;
68  std::string execLine;
69  std::string _i2pBaseDir;
70private:
71  const fp_proc_t& executingFn;
72  const fp_t& exitCallbackFn;
73};
74
75
Note: See TracBrowser for help on using the repository browser.