Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous IO πŸ‘―β€β™€οΈπŸ‘―β€β™‚οΈ #39

Merged
merged 8 commits into from
Jan 29, 2019
1 change: 0 additions & 1 deletion renderer-macos/lib/stubs/BriskApplication.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#import <caml/threads.h>

void ml_NSApplication_init() {
brisk_init();
NSApplication *app = [NSApplication sharedApplication];
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
[app activateIgnoringOtherApps:YES];
Expand Down
8 changes: 2 additions & 6 deletions renderer-macos/lib/stubs/BriskCocoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
#import "BriskWindowDelegate.h"
#import <caml/threads.h>

NSMutableSet *retainedViews;

void brisk_init() { retainedViews = [NSMutableSet new]; }

void brisk_caml_memoize(const char *name, value **staticPointer) {
if (*staticPointer == NULL) {
*staticPointer = caml_named_value(name);
Expand All @@ -20,6 +16,6 @@ void brisk_caml_call(value f) {
caml_release_runtime_system();
}

void retainView(NSView *view) { [retainedViews addObject:view]; }
void retainView(NSView *view) { [view retain]; }
wokalski marked this conversation as resolved.
Show resolved Hide resolved

void releaseView(NSView *view) { [retainedViews removeObject:view]; }
void releaseView(NSView *view) { [view release]; }
12 changes: 4 additions & 8 deletions renderer-macos/lib/stubs/BriskCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
#import <caml/callback.h>
#import <caml/memory.h>

// Memoize registered OCaml callbacks
void brisk_caml_memoize(const char *name, value **staticPointer);

// Enter OCaml runtime and obtain the semaphore
void brisk_caml_call(value callback);

// Call during app launch before any OCaml code is called
void brisk_init();

void brisk_caml_memoize(const char *name, value **staticPointer);

// Manual memory management of NSViews. Maybe there's a way to remove it and
// somehow let ARC do the job even when values cross the boundary. I doubt it
// though.
// Manual memory management of NSViews
void retainView(NSView *view);
void releaseView(NSView *view);
1 change: 1 addition & 0 deletions renderer-macos/lib/stubs/BriskView.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ NSView *ml_NSView_make() {

void ml_NSView_addSubview(NSView *view, NSView *child) {
[view addSubview:child];
releaseView(child);
}

void ml_NSView_removeSubview(NSView *child) { [child removeFromSuperview]; }
Expand Down