-
Notifications
You must be signed in to change notification settings - Fork 135
Sleeping negative delay #2478
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
Open
Ruzihm
wants to merge
37
commits into
OpenDreamProject:master
Choose a base branch
from
Ruzihm:sleeping-negative-delay
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sleeping negative delay #2478
Changes from 22 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
0e13edb
Add YieldOrder tests
Cyberboss 4f0b534
Fix yield scheduling
Cyberboss 0911a5e
Fix ProcScheduler state poisoning between tests
Cyberboss f0e4f27
Up DMTests timeout x10 for slow Windows runners
Cyberboss 86fb394
Redo sleeping as an opcode
Cyberboss 8d7ebeb
Emit constant folded `BackgroundSleep` opcode on negative values othe…
Cyberboss 8c66a1d
Merge master
Cyberboss 1e4dd81
Clear ProcScheduler state each test run
Cyberboss 7dce998
Merge remote-tracking branch 'upstream/master' into 1262-SmartYield
Cyberboss 38e1ff4
Create `IOpenDreamGameTiming`
Cyberboss e3cecd2
Merge remote-tracking branch 'upstream/master' into 1262-SmartYield
Cyberboss dfc4de4
Correct tick timing for DMTests
Cyberboss 591eb09
Add a failing test
Cyberboss cb18a4e
Fix ProcStatus returned from SleepState
Cyberboss eebf85b
Merge remote-tracking branch 'upstream/master' into 1262-SmartYield
Cyberboss 447db24
attempt at continuing work from @Cyberboss #1539
Ruzihm 29dce91
Merge remote-tracking branch 'cyberboss/1262-SmartYield' into sleepin…
Ruzihm 20e439f
implements pseudo scheduling by doing a same-tick yield when 10 negat…
Ruzihm 16e02b5
Merge remote-tracking branch 'upstream/master' into sleeping-negative…
Ruzihm 62e8eb5
track threads and procs for negative sleep interruption timing
Ruzihm 6ae008e
add back the background attribute check
Ruzihm b05a0aa
update delay comment
Ruzihm 25f4801
adds support for certain statements (so far only sleep) as or increm…
Ruzihm de96c6a
remove requirement for sleep delay expression
Ruzihm 3a636bd
Fixes disassembly view of sleep, remove accidental using
Ruzihm 881b84f
lint
Ruzihm fb391fd
lint
Ruzihm 03d85c6
Merge branch 'master' into sleeping-negative-delay
Ruzihm ce67290
lint
Ruzihm cf55e73
simplify sleep tests
Ruzihm ec21474
shorten sleep unit test
Ruzihm 74e57c7
tabs instead of spaces in basic sleep test, shorten sleep yield order…
Ruzihm f18bf82
remove stray leading bytes from basic sleeping test
Ruzihm bc9d8a6
remove logging from yield order sleep test
Ruzihm a80c2c6
Merge branch 'master' into sleeping-negative-delay
Ruzihm 5fc688e
update readonly/partial for dependency classes
Ruzihm bdcef69
update partial/readonly for dependency related stuff
Ruzihm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // RETURN TRUE | ||
|
|
||
| var/should_be_set = FALSE | ||
|
|
||
| /proc/RunTest() | ||
| ASSERT(world.time == 0) | ||
| sleep(world.tick_lag) | ||
| ASSERT(world.time == 1) | ||
| sleep(10) | ||
| ASSERT(world.time == 11) | ||
| StackCheck() | ||
| ASSERT(world.time == 61) | ||
| ASSERT(should_be_set) | ||
| return TRUE | ||
|
|
||
| /proc/StackCheck() | ||
| ASSERT(world.time == 11) | ||
| sleep(50) | ||
| ASSERT(world.time == 61) | ||
| should_be_set = TRUE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| var/counter | ||
| #define ExpectOrder(n) ASSERT(++counter == ##n) | ||
|
|
||
| /proc/BackgroundSleep(delay, expect) | ||
| set waitfor = FALSE | ||
| sleep(delay) | ||
| world.log << "Expect: [expect]" | ||
| ExpectOrder(expect) | ||
|
|
||
| #define MODE_INLINE 0 // spawn | ||
| #define MODE_BACKGROUND 1 // set waitfor = FALSE + sleep | ||
| #define MODE_RAND 2 // random seeded | ||
|
|
||
| #define TestSleep(delay, expect) if(mode == MODE_INLINE || (mode == MODE_RAND && prob(50))){ spawn(##delay) { ExpectOrder(##expect); } } else { BackgroundSleep(##delay, ##expect); } | ||
|
|
||
| /proc/TestSequence(mode) | ||
| counter = 0 | ||
| var/start_tick = world.time | ||
|
|
||
| TestSleep(0, 2) | ||
| ExpectOrder(1) | ||
| sleep(0) | ||
| ExpectOrder(3) | ||
|
|
||
| TestSleep(-1, 4) | ||
| ExpectOrder(5) | ||
|
|
||
| TestSleep(0, 11) | ||
| sleep(-1) | ||
| ExpectOrder(6) | ||
|
|
||
| TestSleep(-1, 7) | ||
| ExpectOrder(8) | ||
| sleep(-1) | ||
| ExpectOrder(9) | ||
|
|
||
| TestSleep(1, 13) | ||
| sleep(-1) | ||
| ExpectOrder(10) | ||
| sleep(0) | ||
| ExpectOrder(12) | ||
|
|
||
| ASSERT(world.time == start_tick) | ||
|
|
||
| sleep(1) | ||
| ExpectOrder(14) | ||
|
|
||
| /proc/RunTest() | ||
| world.log << "Inline:" | ||
| TestSequence(MODE_INLINE) | ||
|
|
||
| world.log << "Background:" | ||
| TestSequence(MODE_BACKGROUND) | ||
|
|
||
| rand_seed(22475) | ||
| for(var/i in 1 to 10000) | ||
| world.log << "Rand-[i]:" | ||
| TestSequence(MODE_RAND) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| using OpenDreamRuntime.Procs; | ||
|
|
||
| using Robust.Shared.IoC; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| using System; | ||
|
|
||
| namespace Content.Tests { | ||
| sealed class DummyOpenDreamGameTiming : IOpenDreamGameTiming { | ||
|
|
||
| [Dependency] IGameTiming _gameTiming = null!; | ||
|
|
||
| public GameTick CurTick { get; set; } | ||
|
|
||
| public TimeSpan LastTick => _gameTiming.LastTick; | ||
|
|
||
| public TimeSpan RealTime => _gameTiming.RealTime; | ||
|
|
||
| public TimeSpan TickPeriod => _gameTiming.TickPeriod; | ||
|
|
||
| public ushort TickRate { | ||
| get => _gameTiming.TickRate; | ||
| set => _gameTiming.TickRate = value; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.