Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Add pseudo- multithreading #26

Open
RiedleroD opened this issue Jan 10, 2021 · 0 comments
Open

Add pseudo- multithreading #26

RiedleroD opened this issue Jan 10, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@RiedleroD
Copy link
Owner

RiedleroD commented Jan 10, 2021

Should be somewhat possible to implement something like this with a few new actions:

  • NEW_THREAD(*args,**kwargs)
    Creates a new thread and supplies the specified *args and **kwargs to the thread constructor
  • LOCK_LOCK(n)
    waits until the nth lock is released & locks it
  • RELEASE_LOCK(n)
    releases the nth lock
  • WAIT_LOCK(n)
    waits until the nth lock is released

and Algorithm callbacks:

  • new_thread(*args,**kwargs):
    (algorithms may define it without *args and **kwargs)
    gets called when NEW_THREAD is yielded, and should return a new generator that inherits BaseAlgorithm.
    (this is a classmethod)

Threads should be handled like separate algorithms, where each non-waiting thread gets called equally often than the others. This should be implemented by calling them 'in a circle'. If an algorithm yields to wait, the member thread.lock should be set to the number that is specified. Every time a thread should be called, its member thread.lock has to be read & checked. If the lock is currently locked, the thread should not be called & it should continue with the next one. If a full round has been completed without a thread being called, the algorithm should be stopped and the user should be notified (per print) that a deadlock has occured.

@RiedleroD RiedleroD self-assigned this Jan 10, 2021
@RiedleroD RiedleroD added the enhancement New feature or request label Jan 10, 2021
@RiedleroD RiedleroD modified the milestones: 0.1, 0.2 Jan 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant