diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-03 15:53:34 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-03 15:53:34 +0200 |
commit | 44c617f7b756052c7cd059c96f89b85f0f5ec96c (patch) | |
tree | a9ac504d7ffa09500c9ea17bab963f1016f6fe79 /src/lanes.lua | |
parent | 420e50697cd036a0d8ea1601961bd6974703ade1 (diff) | |
download | lanes-44c617f7b756052c7cd059c96f89b85f0f5ec96c.tar.gz lanes-44c617f7b756052c7cd059c96f89b85f0f5ec96c.tar.bz2 lanes-44c617f7b756052c7cd059c96f89b85f0f5ec96c.zip |
Moved lanes.sleep implementation to the C-side
Diffstat (limited to 'src/lanes.lua')
-rw-r--r-- | src/lanes.lua | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/src/lanes.lua b/src/lanes.lua index f5e81d4..4f11033 100644 --- a/src/lanes.lua +++ b/src/lanes.lua | |||
@@ -644,26 +644,6 @@ local configure_timers = function() | |||
644 | end -- configure_timers() | 644 | end -- configure_timers() |
645 | 645 | ||
646 | -- ################################################################################################# | 646 | -- ################################################################################################# |
647 | -- ###################################### lanes.sleep() ############################################ | ||
648 | -- ################################################################################################# | ||
649 | |||
650 | -- nil, "timeout" = sleep([seconds_]) | ||
651 | -- | ||
652 | -- PUBLIC LANES API | ||
653 | local sleep = function(seconds_) | ||
654 | local type = type(seconds_) | ||
655 | if type == "string" then | ||
656 | seconds_ = (seconds_ ~= 'indefinitely') and tonumber(seconds_) or nil | ||
657 | elseif type == "nil" then | ||
658 | seconds_ = 0 | ||
659 | elseif type ~= "number" then | ||
660 | error("invalid duration " .. string_format("%q", tostring(seconds_))) | ||
661 | end | ||
662 | -- receive data on a channel no-one ever sends anything, thus blocking for the specified duration | ||
663 | return timerLinda:receive(seconds_, "ac100de1-a696-4619-b2f0-a26de9d58ab8") | ||
664 | end -- sleep() | ||
665 | |||
666 | -- ################################################################################################# | ||
667 | -- ##################################### lanes.genlock() ########################################### | 647 | -- ##################################### lanes.genlock() ########################################### |
668 | -- ################################################################################################# | 648 | -- ################################################################################################# |
669 | -- These functions are just surface sugar, but make solutions easier to read. | 649 | -- These functions are just surface sugar, but make solutions easier to read. |
@@ -799,22 +779,22 @@ local configure = function(settings_) | |||
799 | 779 | ||
800 | -- activate full interface | 780 | -- activate full interface |
801 | lanes.cancel_error = core.cancel_error | 781 | lanes.cancel_error = core.cancel_error |
782 | lanes.finally = core.finally | ||
802 | lanes.linda = core.linda | 783 | lanes.linda = core.linda |
803 | lanes.nameof = core.nameof | 784 | lanes.nameof = core.nameof |
804 | lanes.now_secs = core.now_secs | 785 | lanes.now_secs = core.now_secs |
805 | lanes.null = core.null | 786 | lanes.null = core.null |
806 | lanes.require = core.require | ||
807 | lanes.register = core.register | 787 | lanes.register = core.register |
808 | lanes.finally = core.finally | 788 | lanes.require = core.require |
809 | lanes.set_singlethreaded = core.set_singlethreaded | 789 | lanes.set_singlethreaded = core.set_singlethreaded |
810 | lanes.set_thread_affinity = core.set_thread_affinity | 790 | lanes.set_thread_affinity = core.set_thread_affinity |
811 | lanes.set_thread_priority = core.set_thread_priority | 791 | lanes.set_thread_priority = core.set_thread_priority |
792 | lanes.sleep = core.sleep | ||
812 | lanes.threads = core.threads or function() error "lane tracking is not available" end -- core.threads isn't registered if settings.track_lanes is false | 793 | lanes.threads = core.threads or function() error "lane tracking is not available" end -- core.threads isn't registered if settings.track_lanes is false |
813 | 794 | ||
814 | lanes.gen = gen | 795 | lanes.gen = gen |
815 | lanes.genatomic = genatomic | 796 | lanes.genatomic = genatomic |
816 | lanes.genlock = genlock | 797 | lanes.genlock = genlock |
817 | lanes.sleep = sleep | ||
818 | lanes.timer = timer | 798 | lanes.timer = timer |
819 | lanes.timer_lane = timer_lane | 799 | lanes.timer_lane = timer_lane |
820 | lanes.timers = timers | 800 | lanes.timers = timers |