Announcement

Collapse
No announcement yet.

Blueprint Semaphore?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Blueprint Semaphore?

    I'm working with some async gameplay tasks and I want all of them to complete before moving on. This would normally be done with a Semaphore but I don't see any support for that.

    How easy is it to write that for use in blueprint? I'm not sure how threadsafe it is to just have a UPROPERTY for a countdown object. In fact I'm not sure how threadsafe blueprint is at all, or maybe it is threadsafe and I don't have to worry at all about this?

    #2
    Concurrency idioms and design patterns are not part of blueprints. At least not directly. You have a few options in code to safely expose these async tasks to the gameplay.
    Depending on the platforms and library you use, you could obviously use or write a semaphore, other options would be to use a callback. The handler concept is exposed to blueprint, example is the timer handler. The best is to write your algorithm to be inherently safe... dead/live lock guarantees, progress guarantees, atomicity, ...
    From your description I would go for a handler.

    Comment


      #3
      There are already callbacks for things like GameplayTaskDone and in those callbacks is where I would tell the semaphore to count down its number of locks. The problem is the countdown has to be threadsafe. I may look at C++ support if I need it.

      I found an abilityTask called StartAbilityState that seems to do something similar to what I need. I can extend it a little to get the behavior I want of acting like a gate that helps me wait for multiple other tasks to complete.

      Comment

      Working...
      X