Skip to content

Commit

Permalink
feat!: remove class constructor from main function. When single-threa…
Browse files Browse the repository at this point in the history
…ded it gets loaded the same way as multithreaded would
  • Loading branch information
Julusian committed May 12, 2020
1 parent 1cce227 commit f0c0e3f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 59 deletions.
18 changes: 9 additions & 9 deletions src/__tests__/restarting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('restarts', () => {
expect(ThreadedClassManager.getThreadCount()).toEqual(0)
})
test('restart instance', async () => {
let threaded = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', TestClass, [])
let threaded = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', [])
let onClosed = jest.fn(() => {
// oh dear, the process was closed
})
Expand All @@ -47,9 +47,9 @@ describe('restarts', () => {

})
test('restart instance with multiple', async () => {
let threaded0 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', TestClass, [], { threadUsage: 0.1 })
let threaded1 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', TestClass, [], { threadUsage: 0.1 })
let threaded2 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', TestClass, [], { threadUsage: 0.1 })
let threaded0 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', [], { threadUsage: 0.1 })
let threaded1 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', [], { threadUsage: 0.1 })
let threaded2 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', [], { threadUsage: 0.1 })
let onClosed0 = jest.fn()
let onClosed1 = jest.fn()
let onClosed2 = jest.fn()
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('restarts', () => {
test('force restart', async () => {
expect(ThreadedClassManager.getThreadCount()).toEqual(0)

let thread0 = await threadedClass<House, typeof House>(HOUSE_PATH, 'House', House, [['south0'], []])
let thread0 = await threadedClass<House, typeof House>(HOUSE_PATH, 'House', [['south0'], []])
let onClosed = jest.fn()
ThreadedClassManager.onEvent(thread0, 'thread_closed', onClosed)

Expand All @@ -121,7 +121,7 @@ describe('restarts', () => {
test('child process crash', async () => {
expect(ThreadedClassManager.getThreadCount()).toEqual(0)

let thread0 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', TestClass, [])
let thread0 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', [])
let onClosed = jest.fn()
ThreadedClassManager.onEvent(thread0, 'thread_closed', onClosed)

Expand All @@ -145,11 +145,11 @@ describe('restarts', () => {
test('automatic restart', async () => {
expect(ThreadedClassManager.getThreadCount()).toEqual(0)

let thread0 = await threadedClass<House, typeof House>(HOUSE_PATH, 'House', House, [['south0'], []],{
let thread0 = await threadedClass<House, typeof House>(HOUSE_PATH, 'House', [['south0'], []],{
autoRestart: true,
threadUsage: 0.5
})
let thread1 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', TestClass, [],{
let thread1 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', [],{
autoRestart: true,
threadUsage: 0.5
})
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('restarts', () => {
test('orphan monitoring', async () => {
expect(ThreadedClassManager.getThreadCount()).toEqual(0)

let thread1 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', TestClass, [],{
let thread1 = await threadedClass<TestClass, typeof TestClass>(TESTCLASS_PATH, 'TestClass', [],{
autoRestart: true,
threadUsage: 0.5,
freezeLimit: 200
Expand Down
Loading

0 comments on commit f0c0e3f

Please sign in to comment.