Skip to content

Commit 3f48eb7

Browse files
committed
First stab at Playground Blueprints
1 parent c588dec commit 3f48eb7

File tree

6 files changed

+423
-72
lines changed

6 files changed

+423
-72
lines changed

packages/php-wasm/common/src/lib/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ export type {
1717
WithPHPIniBindings,
1818
} from './php';
1919

20+
import Semaphore from './semaphore';
21+
export { Semaphore };
22+
2023
export { jsToPHPTranslator } from './js-to-php-translator';
2124
export type { PHPResponse } from './php-response';
2225
export type { ErrnoError } from './rethrow-file-system-error';
23-
2426
export {
2527
LatestSupportedPHPVersion,
2628
SupportedPHPVersions,

packages/php-wasm/common/src/lib/semaphore.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,14 @@ export default class Semaphore {
3434
}
3535
}
3636
}
37+
38+
async run<T>(fn: () => Promise<T>): Promise<T> {
39+
const release = await this.acquire();
40+
try {
41+
return await fn();
42+
} finally {
43+
release();
44+
}
45+
}
46+
3747
}

packages/php-wasm/web/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export {
66
PHPBrowser,
77
exposeAPI,
88
consumeAPI,
9+
Semaphore,
910
jsToPHPTranslator,
1011
SupportedPHPVersions,
1112
SupportedPHPVersionsList,

0 commit comments

Comments
 (0)