Skip to content

Question: unusable sample code #400

Open
@pbelbin

Description

@pbelbin

I'm doing some usage of your package, with TypeScript.

I see in your documentation an example that shows:

let pool: Pool<ThreadType>

Well, perhaps I'm missing something, but ThreadType is not exposed it seems (or, it's hidden somewhere)? Or, is this supposed to be a placeholder for something else?

I want to declare (with type information) a variable like what you've shown, but, like I said, it seems ThreadType is not exposed.

What's supposed to be used here?

Another issue is that when I do something like this:

const x = Pool(spawnWorker, 1);

VSCode is able to show me that x has been attributed a type of:

const x: WorkerPool<FunctionThread<[filename: string], string | Result>>

But, again, it seems I am not able to import all of these discreet types :(

What I really want to be able to do is say that I have an object having a variable/as yet unknown number of (referenced by string key) Pool(()=> spawn<WorkerFunction>(new Worker('./worker')), 1) results.

eg:

	const spawnWorker = () => spawn<WorkerFunction>(new Worker('./worker'));
	
	const pools: {
		[index: string]: WorkerPool<FunctionThread<[filename: string], string | Result>>;
	} = {};

so I can add to my pools like this:

     pools['thing1'] = Pool(spawnWorker, 1);

But, again, WorkerPool and Result do not appear to be exposed.

A little help please?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions