Skip to content

Commit

Permalink
use lightning-pool
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanahiro committed Jul 26, 2024
1 parent e8e29aa commit 7254c37
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
32 changes: 29 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
"better-sqlite3": "^9.6.0",
"commander": "^11.0.0",
"file-system-cache": "^2.4.4",
"generic-pool": "^3.9.0",
"hono": "^4.3.0",
"lightning-pool": "^4.2.2",
"memory-cache-node": "^1.4.0",
"pmtiles": "^3.0.5",
"sharp": "^0.32.5"
}
}
}
6 changes: 3 additions & 3 deletions src/render/pool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from 'path';

import mbgl from '@maplibre/maplibre-gl-native';
import genericPool from 'generic-pool';
import { Pool } from 'lightning-pool';
import type { StyleSpecification } from '@maplibre/maplibre-gl-style-spec';

import { getSource } from '../source/index.js';
Expand Down Expand Up @@ -34,15 +34,15 @@ function handleFileExt(uri: string) {
}

// key:value = styleJsonString:Pooled Map Instance
const mapPoolDict: Record<string, genericPool.Pool<mbgl.Map>> = {};
const mapPoolDict: Record<string, Pool<mbgl.Map>> = {};
async function getRenderPool(
style: StyleSpecification,
cache: Cache,
mode: 'tile' | 'static',
) {
const dictKey = JSON.stringify(style);
if (mapPoolDict[dictKey] === undefined) {
const pool = genericPool.createPool({
const pool = new Pool({

Check warning on line 45 in src/render/pool.ts

View check run for this annotation

Codecov / codecov/patch

src/render/pool.ts#L45

Added line #L45 was not covered by tests
create: async () => {
const map = new mbgl.Map({
request: function (req, callback) {
Expand Down

0 comments on commit 7254c37

Please sign in to comment.