Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing of thread #9

Closed
levBagryansky opened this issue Aug 28, 2022 · 7 comments
Closed

testing of thread #9

levBagryansky opened this issue Aug 28, 2022 · 7 comments

Comments

@levBagryansky
Copy link
Member

levBagryansky commented Aug 28, 2022

To be sure thread dataizes it's argument slow after start we can implement time and sleep objects that helps to regulate dataization time sleep does it) and measure (time does it) :
[millis] > sleep stops dataization for millis milliseconds
[] > time is an analog of System.currentTimeMillis() in java.
So we can write

[] > test-it-dataizes-after-start
  thread > a
    sleep 3000
  thread > b
    sleep 3000
  memory 0 > m1
  memory 0 > m2
  seq > @
    m1.write
      time
    a.start
    b.start
    a.join
    b.join
    m2.write
      time
    gt.
      4000
      minus.
        m1
        m2

Here we can be sure a and b works in parallel.
@yegor256 @mximp What do you think?

@mximp
Copy link

mximp commented Aug 29, 2022

@levBagryansky
Maybe it's better to have sleep method as thread attribute. In this case we can use it with passing thread into executable (as suggested earlier by @yegor256):

[] > sleep-test
  thread > a
    [t]
      (t.sleep 3000) > @

For the time object - we've just implemented such function in eo.sys: objectionary/eo-sys#5

@levBagryansky
Copy link
Member Author

levBagryansky commented Aug 29, 2022

@mximp
We can address to thread by ^.
Since sleep will be dataized in current thread it's not necessary make it thread's attribute. But thread.sleep will give us ability to addres to foreign thread:

thread > a
  ...
thread > b
  seq > @
    a.sleep
    ...

I don't know is it ok for us or not.

@mximp
Copy link

mximp commented Aug 29, 2022

@levBagryansky sleep is an internal will of the execution thread. No one outside can ask a thread to sleep. A thread can be asked for interruption though (interrupt in Java).
So maybe you're right: we can have object org.eolang.threads.sleep which dataization would just do nothing for provided number of millis.

@levBagryansky
Copy link
Member Author

levBagryansky commented Aug 29, 2022

@yegor256 what do you think?

@yegor256
Copy link
Member

@levBagryansky I think it's a good idea to have QQ.threads.sleep object, which makes dataization pause for the given amount of milliseconds

@mximp
Copy link

mximp commented Aug 29, 2022

@levBagryansky please create separate issue for implementing sleep object.

@levBagryansky
Copy link
Member Author

@mximp ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants